是否有可能以编程方式显示在浏览器Android版地址栏? [英] Is it possible to programmatically show URL bar in Chrome for Android?

查看:173
本文介绍了是否有可能以编程方式显示在浏览器Android版地址栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在默认情况下,它就会显示只有当设备的菜单按钮pssed $ P $和网页时刷下来(见下面的GIF当触摸标记为红色)。可地址栏显示使用JavaScript?

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). Can the URL bar be shown using JavaScript?

推荐答案

这是因为全屏API的限制,用户输入只能看到演示

The solution

It is possible only on user input, because of the limitations of the 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);
}

重要提示

  • 在此功能仅在测试的铬35.0 .1916.141,在三星Galaxy S4 ,运行Android 4.4.2。
  • 在其他设备,可能需要为增加超时
  • 在其他浏览器
  • 要避免的错误,使用<一个href="https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode#Toggling_fullscreen_mode"相对=nofollow>一个跨浏览器实现的全屏API函数的WebKit的,而不是。
  • 这是怎样的一个黑客,所以它的有可能成为浏览器的未来版本无效
  • 有些滞后可以看出,因为600毫秒超时,但功能将是不正常的,没有它。
  • 我查了一些其他的方法都没有成功。改变使用 window.location的整个URL使得地址栏重新出现,但离开/重新加载页面是一个不良副作用。只改变 window.location.hash 或使用 window.history 也没有帮助,即使URL被修改。无 window.scrollBy window.scrollTo window.scrollTop 帮助。
  • Important notes

    • This function is tested only in Chrome 35.0.1916.141, on Samsung Galaxy S4, running Android 4.4.2.
    • On other devices, it might be necessary to increase the timeouts.
    • To avoid errors in other browsers, use a cross-browser implementation of the Full Screen API functions instead of webkit's.
    • This is kind of a hack, so it might become ineffective in future releases of Chrome.
    • Some lag can be seen because of the 600 ms timeout, but the function would be dysfunctional without it.
    • I've checked some other approaches without success. Changing the entire URL using window.location makes the address bar reappear, but leaving/reloading the page is an undesirable side effect. Changing only window.location.hash or using window.history doesn't help either, even if the URL is modified. None of window.scrollBy, window.scrollTo, window.scrollTop helps.
    • 这篇关于是否有可能以编程方式显示在浏览器Android版地址栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆