Javascript 的`window.resizeTo` 不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7602078/
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
Javascript's `window.resizeTo` isn't working
提问by zzzzBov
I'm trying to create a bookmarklet to do some very specific resizing to do browser size testing, and I can't seem to get the web browser to resize using window.resizeTo
.
我正在尝试创建一个书签来进行一些非常具体的调整大小以进行浏览器大小测试,但我似乎无法使用window.resizeTo
.
Overly simplified example that doesn't work:
过于简化的例子不起作用:
javascript:window.resizeTo(1024,600);
I can understand that browsers might have disabled this feature, but here's a screenshot of my JavaScript Settings in Firefox:
我可以理解浏览器可能已禁用此功能,但这是我在 Firefox 中的 JavaScript 设置的屏幕截图:
Am I missing something obvious or should I file a bug report?
我是否遗漏了一些明显的东西,还是应该提交错误报告?
回答by Viktor
According to this bug report, this is a new feature, not a bug. Specifically:
根据此错误报告,这是一项新功能,而不是错误。具体来说:
Two rules:
- Can't resize a window/tab that hasn't been created by window.open.
- Can't resize a tab if the tab is in a window with more than one tab.
两条规则:
- 无法调整不是由 window.open 创建的窗口/选项卡的大小。
- 如果选项卡位于具有多个选项卡的窗口中,则无法调整选项卡的大小。
If I understand this "fix" correctly, you can resize only your own popup windows, not the main window.
如果我正确理解了这个“修复”,您只能调整自己的弹出窗口的大小,而不是主窗口的大小。