javascript "resizeTo" 函数在 Chrome 和 Opera 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3641648/
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
The javascript "resizeTo" function not working in Chrome and Opera
提问by Zakaria
The resizeTo (that allows setting a new height/width value) function works great on Firefox and Internet Explorer and doesn't work at all on Chrome and Opera.
resizeTo(允许设置新的高度/宽度值)函数在 Firefox 和 Internet Explorer 上运行良好,在 Chrome 和 Opera 上根本不起作用。
Is there another function that does the same and works on all the browsers?
是否有另一个功能相同并适用于所有浏览器?
Thank you,
谢谢,
Regards
问候
采纳答案by Guffa
No, there isn't another function.
不,没有其他功能。
The resizeTomethod is disabled by default in several browsers, and I know that it can also be manually disabled in Firefox.
该resizeTo方法在多个浏览器中默认禁用,我知道也可以在 Firefox 中手动禁用它。
It has been widely misused, so most browser vendors feel that it should be disabled, or at least a user controllable option.
它已被广泛滥用,因此大多数浏览器供应商认为应该禁用它,或者至少是用户可控的选项。
回答by Michel
On my way it isn't possible to resize the window when it is on top-level. (so not a pop-up)
在我的方式中,当窗口位于顶层时无法调整窗口大小。(所以不是弹出窗口)
And i think that chrome got it right by not allowing top level windows to be resized.
而且我认为 chrome 通过不允许调整顶级窗口的大小来做到这一点。
You can solve it:
你可以解决它:
Resizing won't work for top-level tabs, and when you open sample.htm it's opened as a top-level tab. If you instead opened it as a pop-up (for example using window.open with a width and a height set), resizeTo should work.
调整大小不适用于顶级选项卡,当您打开 sample.htm 时,它会作为顶级选项卡打开。如果您改为将其作为弹出窗口打开(例如使用设置了宽度和高度的 window.open),则 resizeTo 应该可以工作。
回答by user2931920
Because many webmasters have made a bad use of pop-ups and resizing, some uncompromisingbrowser manufacturers hopelessly just disable these functions. Other more respectful manufacturers leave them as optional.
由于很多站长对弹出窗口和调整大小的使用不当,一些不妥协的浏览器制造商只能无奈地禁用这些功能。其他更受尊重的制造商将它们作为可选。

