Javascript 在WebView中,js函数window.innerHeight只返回0?

Javascript 在WebView中,js函数window.innerHeight只返回0?,javascript,android,webview,Javascript,Android,Webview,我正在用Android开发一个web应用程序,我使用WebView来播放一些页面。下面是我的html代码,我编写了一个js函数来获取浏览器屏幕的高度 <html> <head> <script> window.onload=function(){ alert(window.innerHeight); } </script> </head> <body style="background:black;"> </b

我正在用Android开发一个web应用程序,我使用WebView来播放一些页面。下面是我的html代码,我编写了一个js函数来获取浏览器屏幕的高度

<html>
<head>
<script>
window.onload=function(){
    alert(window.innerHeight);
}
</script>
</head>
<body style="background:black;">
</body>
</html>

window.onload=function(){
警报(窗口内高度);
}
我在我的Defy 480*800移动设备中测试了上述代码,在WebView中,它只返回0,有时返回其他数字。但在浏览器中,它工作正常

所以我想知道是否有什么东西我应该知道,以获得可用的屏幕高度在WebView


更新:2012.3.13

谢谢Demonick,我按照你的建议找到了lazyload.js,我使用setTimeout来进行投票以获得窗口的高度

希望它能帮助别人

<script>
//poll numbers
var pollCount=0;

//get the window Height
var pollWindowHeight=function(){
    //poll the window innerHeight 10s
    if(window.innerHeight==0){
        pollCount+=1;

        if(pollCount<200)   {
            setTimeout(pollWindowHeight,50);
        }else{
            //just stop polling or you can do some others
        }
    }else{
        //use the window.innerHeight to do something...
    }
}
document.addEventListener("DOMContentLoaded",pollWindowHeight, false);
</script>

//民调数字
var-pollCount=0;
//获取窗口高度
var pollWindowHeight=函数(){
//将窗内高度轮询为10秒
if(window.innerHeight==0){
pollCount+=1;

如果(pollCount尝试将
窗口.innerHeight
函数放在
document.onready
或更高版本中,因为高度可能尚未在
onload
上初始化