9

加载网络应用程序时,我需要隐藏 ipod touch 中的 URL 栏,我尝试了在线找到的所有可能解决方案,包括此处找到的解决方案: http ://www.iphonemicrosites.com/tutorials/how-to-hide-the-移动浏览器中的地址栏/

并在 CSS 中设置 min-height,但它只适用于横向和配置文件模式,它只隐藏 URL 栏的一部分而不是整个栏。有人知道吗?谢谢。

下面是我的代码:

<meta name="app-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-touch-fullscreen" content="YES" />
<meta name="viewport" content="width=320;initial-scale=0.6666;;minimum-scale=0.6666; maximun-scale=1.0;"/>


<title>Test</title>
<script type="application/x-javascript">

addEventListener("load", function()
{
    setTimeout(updateLayout, 0);
}, false);

var currentWidth = 0;

function updateLayout()
{
    if (window.innerWidth != currentWidth)
    {
        currentWidth = window.innerWidth;

        var orient = currentWidth == 320 ? "profile" : "landscape";
        document.body.setAttribute("orient", orient);
        setTimeout(function()
        {
            window.scrollTo(0, 1);
        }, 100);
    }
}

setInterval(updateLayout, 100);

</script>
<link media="only screen and (max-device-width: 320px)" href="style.css" rel="stylesheet" type="text/css" />

...

4

4 回答 4

7

这对我有用:

<body onload="setTimeout(function() { window.scrollTo(0, 1) }, 100);">
于 2010-08-11T01:26:42.580 回答
2

您的代码中有一些拼写错误。尝试

<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-touch-fullscreen" content="YES" />
<meta name="viewport" content="width=320;initial-scale=0.6666;minimum-scale=0.6666; maximum-scale=1.0;"/>

(我将“app”更改为“apple”,删除了一个额外的分号,并将“maximun”更改为“maximum”。)

于 2012-12-09T17:27:41.007 回答
1

你试过iUI吗?http://code.google.com/p/iui/

您拥有的代码似乎只是为了使页面全屏显示而选择的 iUI,但我想知道您是否有特定的理由不使用完整的脚本。我曾经使用过它,除了将脚本添加到页面之外,我不需要做任何其他事情。

于 2010-02-27T03:29:54.970 回答
1

尝试确保您网站内容的长度至少是窗口的高度。Mobile Safari 会将导航栏向上推,但不会在您的页面下方留下灰色的“空白”空间,因此如果您的页面很短,它只会隐藏部分导航栏。

于 2012-05-04T03:01:22.110 回答