1

我在 Chrome 43 上遇到了一个奇怪的错误,步骤如下:-我打开一个页面,比如说 page1.html,然后使用 html5 进入全屏(单击按钮)

  • 我在这个 page1.html 中调整浏览器窗口的大小

  • 然后我单击此页面上的链接,打开另一个页面,比如说 page2.html

  • 浏览器自动关闭全屏,并重定向到page2.html

  • 在 page2.html 中,document.documentElement.offsetWidth/clientWidth 与 window.innerWidth 不同。

  • html 和 body 标签在 page2.html 上设置为 100% 宽度和 100% 高度。

如果我在 page2.html 中触发全屏模式并退出,似乎可以解决此问题

如果我在新窗口中正常打开page2.html document.documentElement.offsetWidth/clientWidth 等于window.innerWidth。

这仅在最后一个 Chrome 中发生。有人知道出了什么问题吗?

为什么全屏触发似乎可以解决问题,全屏模式在浏览器内部触发什么?

模拟这个bug page1.html的代码:

<html>
    <head>
    </head>
    <body style="background-color: red">
        <span onclick="fullmode();">CLICK HERE FOR FULL SCREEN MODE</span>
        <a href="http://stackoverflow.com/">GO TO TO PAGE2.html </a>
        <script>
            function fullmode() {
                if (!document.fullscreenElement &&    // alternative standard method
                    !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) {  // current working methods
                    if (document.documentElement.requestFullscreen) {
                        document.documentElement.requestFullscreen();
                    } else if (document.documentElement.msRequestFullscreen) {
                        document.documentElement.msRequestFullscreen();
                    } else if (document.documentElement.mozRequestFullScreen) {
                        document.documentElement.mozRequestFullScreen();
                    } else if (document.documentElement.webkitRequestFullscreen) {
                        document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
                    }
                } else {
                    if (document.exitFullscreen) {
                        document.exitFullscreen();
                    } else if (document.msExitFullscreen) {
                        document.msExitFullscreen();
                    } else if (document.mozCancelFullScreen) {
                        document.mozCancelFullScreen();
                    } else if (document.webkitExitFullscreen) {
                        document.webkitExitFullscreen();
                    }
                }
            } 
        </script>
    </body>
</html>
4

0 回答 0