javascript 使窗口无法在 Chrome 中调整大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15480252/
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
Make window not resizable in Chrome
提问by Martyn0627
I have some JavaScript that I use to make a window not resizable, something along the lines of:
我有一些 JavaScript 可以用来制作不可调整大小的窗口,大致如下:
window.open(URL, id, "resizable=no");
This works in most browsers but it appears to not be supported in Chrome. I have considered using JavaScript to watch for a re-size and set it back, but this is not ideal. Does anyone have any other suggestions? Thanks in advance.
这适用于大多数浏览器,但似乎不受 Chrome 支持。我曾考虑使用 JavaScript 来观察重新调整大小并将其设置回来,但这并不理想。有人有其他建议吗?提前致谢。
回答by hallvors - restore Monica
This is old school javascript. Modern browsers tend to not allow this because it is seen as a user unfriendly limitation.
这是老派的javascript。现代浏览器往往不允许这样做,因为它被视为对用户不友好的限制。
回答by geoom
This was easy to do with the old javascript with popups and a "resizable = 0" parameter a while ago, but current browsers do not allow this because they killed user's freedom. This initiative started with firefox and chrome followed him, probably the solution for this case is creating an chrome extension and that only works for chrome, but it seems a madness.
使用带有弹出窗口和“resizable = 0”参数的旧 javascript 很容易做到这一点,但当前的浏览器不允许这样做,因为它们扼杀了用户的自由。该计划始于 Firefox,随后 chrome 紧随其后,可能这种情况的解决方案是创建一个 chrome 扩展程序,该扩展程序仅适用于 chrome,但这似乎很疯狂。
After some discussions, the consensus seems to be that window.open() should not be modified to parse "resizeable", at least at this time. The change would require modifications to Webkit, and the behavior would be inconsistent with Firefox and existing Webkit browsers.
经过一些讨论,共识似乎是 window.open() 不应该修改为解析“resizeable”,至少在这个时候是这样。该更改需要对 Webkit 进行修改,并且该行为将与 Firefox 和现有 Webkit 浏览器不一致。
We always allow a window to be resized, which is consistent with Firefox.
我们始终允许调整窗口大小,这与 Firefox 一致。