【问题标题】:On window.open window's width and height not set properly in Windows10在 Windows10 中,window.open 窗口的宽度和高度未正确设置
【发布时间】:2018-03-19 06:37:40
【问题描述】:

我们正在使用 window.Open 打开一个浏览器窗口,并设置桌面的可用宽度和可用高度。 它在除 Windows10 之外的所有 Windows 操作系统上都能完美运行。 IE、Chrome 和 Firefox 在浏览器窗口的右侧和左侧获得了一些空间。我花了很多时间找不到合适的解决方案。有什么办法可以解决这个问题吗?

谢谢,

<script>
        var useragent = navigator.userAgent;
        var tabScreenWidth = screen.availWidth;
        var qsScreenWidth = "&screenWidth=" + tabScreenWidth;

            var str = GetQueryString();

            var MainWindow = window.open('Authentication/PSGLogin.aspx?' + str + qsScreenWidth, '', 'top=0,left=0,resizable=NO,toolbar=no,status=no,directories=no,menubar=no,scrollbars=0', false);

            MainWindow.moveTo(0, 0);
            var WindowWidth = screen.availWidth;
            var WindowHeight = screen.availHeight;
            if (WindowWidth > 1024)
                WindowWidth -= 1;
            MainWindow.resizeTo(WindowWidth, WindowHeight);

            window.opener = self;
            window.open('', '_self');

            setTimeout("retryCloseWindow()", 2000);

        function retryCloseWindow() {
            window.opener = self;
            window.open('', '_self');
            //window.close();
            setTimeout("retryCloseWindow()", 2000);
        }
        function GetQueryString() {
            var qString = location.href;
            var aryString = qString.split('?');
            return aryString[1];
        }

    </script>

【问题讨论】:

  • 我怀疑这是因为 Windows 10 将窗口周围的边框缩小到了 1px。这些浏览器可能尚未更新其对窗口大小的计算以考虑较窄的边框。有趣的是,我可以在 Chrome、IE 和 Firefox 上重现这一点,但不能在 Edge 上重现。

标签: javascript jquery windows-10-desktop maximize-window


【解决方案1】:

通过我这边的测试,浏览器窗口可以正常全屏打开。我在 windows 10 build 16299 中使用 Chrome 浏览器进行了测试。如果您的意思是浏览器的左右两侧有一些空格并且 HTML 页面位于中间,在这种情况下,这取决于您正在打开的页面,与window.open 方法。这是由页面中定义的样式定义的。

尝试在窗口中打开window.open方法页面,该页面似乎正在设置样式以占据浏览器窗口。或者您可以尝试直接在浏览器中打开Authentication/PSGLogin.aspx 页面来查看结果。

【讨论】:

  • 您好 Sunteen,感谢您的回复。在这里,我们使用的是 Windows 10 build 15063.0。并且空格不在浏览器内,它在浏览器窗口之外。我附上了截图,你可以在浏览器周围看到一些空间。谢谢,
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多