javascript Microsoft Edge window.open() 不支持宽度高度,并在后台打开
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30582414/
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
Microsoft Edge window.open() not honoring width height, and opens in background
提问by Sudi
I'm on Windows 10 preview Build 10130, and the window.open
method in the new Edge browser isn't behaving as per the specification.
我在 Windows 10 预览版 Build 10130 上,window.open
新 Edge 浏览器中的方法不符合规范。
If you use the example code in https://msdn.microsoft.com/en-us/library/ms536651(v=vs.85).aspx, and click to open a new window, it will open a new window in the background, and will completely ignore the width and height.
如果您使用https://msdn.microsoft.com/en-us/library/ms536651(v=vs.85).aspx 中的示例代码,然后单击打开一个新窗口,它将在背景,将完全忽略宽度和高度。
<!DOCTYPE html>
<html>
<head>
<title>window.open()</title>
<style>
html, body {
width: 100%;
height: 100%;
border: 1px solid black;
}
</style>
</head>
<body onclick="myOpen();">
<p>Click this page and window.open() is called.</p>
<script>
function myOpen() {
window.open("Sample.htm", null, "height=200, width=400, status=yes, toolbar=no, menubar=no, location=no");
}
</script>
</body>
</html>
Anyone else see this issue? http://jsfiddle.net/TylerH/c91hcoum/2/
还有其他人看到这个问题吗?http://jsfiddle.net/TylerH/c91hcoum/2/
采纳答案by Sudi
This is now resolved in windows build 10162
这现在在 windows build 10162 中得到解决
回答by Rami Sarieddine
The open method documentation and sample code in the URL you shared is aimed at IE and has not been updated yet for Edge. As i have noticed while reading through that page. Edge is still being polished and refined while we are in the insider preview mode. On Build 10162, I got it working here on this JSFiddle http://jsfiddle.net/RamiSarieddine/wu09fh1d/
你分享的 URL 中的开放方法文档和示例代码是针对 IE 的,尚未针对 Edge 进行更新。正如我在阅读该页面时所注意到的那样。当我们处于内部预览模式时,Edge 仍在打磨和完善。在 Build 10162 上,我让它在这个 JSFiddle http://jsfiddle.net/RamiSarieddine/wu09fh1d/ 上工作
window.open("http://dev.modern.ie/community/","_blank","height=500,width=500,scrollbars=yes,location=yes");
window.open("http://dev.modern.ie/community/","_blank","height=500,width=500,scrollbars=yes,location=yes");
you can see the window opening with height 500, width 300 with a scroll bar, mini-maximize and close button. Check the screenshot below.
您可以看到高度为 500,宽度为 300 的窗口打开,带有滚动条、最小最大化和关闭按钮。检查下面的屏幕截图。
window.open("http://dev.modern.ie/community/","_blank","height=500,width=500,scrollbars=yes,location=yes");
window.open("http://dev.modern.ie/community/","_blank","height=500,width=500,scrollbars=yes,location=yes");
回答by Tom K
If the height is higher than the screen (including the browser fluff), the window will be maximized. This is different than the behavior using IE 9, 10, 11.
如果高度高于屏幕(包括浏览器绒毛),则窗口将最大化。这与使用 IE 9、10、11 的行为不同。
This is with RTM Win10 Edge.
这是使用 RTM Win10 Edge。