Android 带有jQuery mobile hide addressbar的WebApp无法工作,因为google浏览器存在高度错误

Android 带有jQuery mobile hide addressbar的WebApp无法工作,因为google浏览器存在高度错误,android,jquery-mobile,hide,fullscreen,address-bar,Android,Jquery Mobile,Hide,Fullscreen,Address Bar,当你在webapps中隐藏地址栏时,你几乎有了原生应用的感觉。不幸的是,只有当内容足够大时,隐藏地址栏才能在jQuery mobile中工作。如果内容太小,则无法正常工作-也适用于全屏和固定页脚-请参阅。原因似乎是Android浏览器中的一个bug。如果内容太小,jQuery funktion$window.height只提供450px的屏幕高度,我使用的是Android 2.3.6和Galaxy S2。缺少地址栏的高度。内容是否足够大,该函数是否能像预期的那样提供508px。这也是一个很好的方

当你在webapps中隐藏地址栏时,你几乎有了原生应用的感觉。不幸的是,只有当内容足够大时,隐藏地址栏才能在jQuery mobile中工作。如果内容太小,则无法正常工作-也适用于全屏和固定页脚-请参阅。原因似乎是Android浏览器中的一个bug。如果内容太小,jQuery funktion$window.height只提供450px的屏幕高度,我使用的是Android 2.3.6和Galaxy S2。缺少地址栏的高度。内容是否足够大,该函数是否能像预期的那样提供508px。这也是一个很好的方法——不起作用。我找到了一个可行的解决方案,但需要500毫秒的延迟。当你加载一小段时间的页面时,它会带来一个翻转的地址栏。有没有另一种方法,即地址栏没有翻转

但也许有人知道这怎么会更好。它与iOS配合得好吗?如果有人能用iPhone测试一下,那就太好了。 提前谢谢

代码如下:

var fixgeometry = function() {                
            /* Calculate the geometry that our content area should take */
            var header = $(".header:visible");
            var footer = $(".footer:visible");
            var content = $(".content:visible");                
            var viewport_height = $(window).height()+60; /*Here is the idea! Make it bigger here and make it later smaller*/
            var content_height = viewport_height - header.outerHeight() - footer.outerHeight();

            /* Trim margin/border/padding height */
            content_height -= (content.outerHeight() - content.height());
            content.height(content_height);
            setTimeout(function(){
                window.scrollTo(0, 1);
                content.height(content_height-60); }, 500 );
        };


$(document).ready(function(){                           
            $(window).bind("orientationchange resize pageshow", fixgeometry);   
      });   

scrollTo函数是在jQuery中实现的,但是在oriantationchange或textfield中的输入之后它就不起作用了。因此,在setTimeout函数中有必要使用它。

我希望您有足够的时间来处理这个问题$window.height和$window.width将为您提供视口尺寸,它们可能因设备和浏览器而异。阅读这篇优秀的文章,也许你会找到一个解决方案。