1

当您在 WebbApps 中隐藏地址栏时,您几乎可以获得原生应用程序的感觉。不幸的是,只有在内容足够大的情况下,才能在 jQuery mobile 中隐藏地址栏。如果内容太小,它不起作用 - 也适用于全屏和固定页脚 - 请参阅http://jquerymobile.com/demos/1.2.0/docs/toolbars/bars-fixed.html。原因似乎是 Android 浏览器中的错误。如果内容太小,jQuery funktion $(window).height() 仅提供 450px 作为屏幕高度(我使用的是带有 Galaxy S2 的 Android 2.3.6)。地址栏的高度缺失。内容是否足够大,功能是否按预期提供 508 像素。也是一个很好的方法 - http://www.semicomplete.com/blog/tags/jquery%20mobile- 不工作。我找到了一个可行的解决方案,但需要延迟 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 中实现,但在方向更改或文本字段中的输入之后不起作用。所以它在 setTimeout 函数中是必要的。

4

0 回答 0