[英]Is it possible to programmatically show URL bar in Chrome for Android?
By default, it gets shown only when the device's menu button is pressed and when the page is swiped down (see the GIF below when the touch marker is red). 默认情况下,仅在按下设备的菜单按钮时以及向下滑动页面时才显示(当触摸标记为红色时,请参阅下面的GIF)。 Can the URL bar be shown using JavaScript? 可以使用JavaScript 显示URL栏吗?
It is possible only on user input , because of the limitations of the Full Screen API. 由于Full Screen API的限制,它仅可以在用户输入上使用 。 See the demo . 看演示 。
var p;
function showURLBar() {
p = [window.pageXOffset, window.pageYOffset];
document.documentElement.webkitRequestFullscreen();
setTimeout(function () {
document.webkitExitFullscreen();
setTimeout(function () {
scrollTo(p[0], p[1]);
}, 300);
}, 300);
}
window.location
makes the address bar reappear, but leaving/reloading the page is an undesirable side effect. 使用window.location
更改整个URL会使地址栏重新出现,但是离开/重新加载页面是一种不良副作用。 Changing only window.location.hash
or using window.history
doesn't help either, even if the URL is modified. 仅更改window.location.hash
或使用window.history
也无济于事,即使URL已被修改。 None of window.scrollBy
, window.scrollTo
, window.scrollTop
helps. window.scrollBy
, window.scrollTo
, window.scrollTop
帮助。 By the use of the word 'device' I'm guessing you mean a mobile device. 通过使用“设备”这个词,我猜你的意思是移动设备。 I fought with this also and just used a shortcut to the page from the desktop of the device. 我也与此斗争,只是从设备桌面使用了页面的快捷方式。 Then you get full screen without the address bar. 然后你没有地址栏就全屏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.