javascript 禁用在移动设备上隐藏地址栏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23164503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 00:27:41  来源:igfitidea点击:

Disable hiding of address bar on mobile

javascripthtmlcssmobile

提问by Randy

I'm working on a mobile website which has "pages" that have div's which take up the screens full size and you can scroll between each one. The problem is, the window resizes whenever a user scrolls downward because the address bar hides. This causes problems when you scroll to the complete bottom and the address bar then hides.

我正在开发一个移动网站,该网站的“页面”具有 div 占据屏幕全尺寸,您可以在每个页面之间滚动。问题是,每当用户向下滚动时,窗口都会调整大小,因为地址栏隐藏了。当您滚动到完整底部并且地址栏然后隐藏时,这会导致问题。

Is it possible to have the address bar always show on mobile devices?

是否可以在移动设备上始终显示地址栏?

回答by u283863

You can wrap your HTML with divand do something like this: http://jsfiddle.net/DerekL/Fhe2x/show

你可以用你的 HTML 包装div并做这样的事情:http: //jsfiddle.net/DerekL/Fhe2x/show

$("html, body, #wrapper").css({
    height: $(window).height()
});

It works on Android and iOS.

它适用于 Android 和 iOS。

回答by Bogdan Mihai

The simplest way to achieve this is to scroll in a container, rather than scrolling the document.

实现此目的的最简单方法是在容器中滚动,而不是滚动文档。

E.g.:

例如:

<html><body>
  <div id="scrollable-content"> ... all your content here ... </div>
</body></html>

html, body {
  height: 100%;
}

#scrollable-content {
  height: 100%;
  overflow-y: scroll;
}

回答by lachlanjc

Are you looking at iPhone? I don't know about Android, but on iOS 7 for iPhone it's not possible. One thing you could do is use minimal-uito have an always-minimized navigation bar, keeping a consistent size for the window:

你在看 iPhone 吗?我不了解 Android,但在 iPhone 的 iOS 7 上这是不可能的。您可以做的一件事是使用minimal-ui始终最小化的导航栏,保持窗口大小一致:

<meta name="viewport" content="width=device-width, minimal-ui">

<meta name="viewport" content="width=device-width, minimal-ui">

http://visuellegedanken.de/2014-03-13/viewport-meta-tag-minimal-ui/

http://visuellegedanken.de/2014-03-13/viewport-meta-tag-minimal-ui/

I hope that helps!

我希望这有帮助!