加载Web应用程序时,我需要在ipod touch中隐藏URL栏,我尝试了所有在线找到的可能解决方案,包括在此处找到的解决方案:
http://www.iphonemicrosites.com/tutorials/how-to-hide-the-address-bar-in-mobilesafari/
并在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" />
...
最佳答案
这对我有用:
<body onload="setTimeout(function() { window.scrollTo(0, 1) }, 100);">