Javascript window.resize 在 chrome 和 opera 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5139323/
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
window.resize is not working in chrome and opera
提问by hema
window.resize is not working in chrome and opera ..how to make it work?
window.resize 在 chrome 和 opera 中不起作用..如何使它工作?
回答by jave.web
There is no window.resize()
没有 window.resize()
...however...
...然而...
There are:
有:
window.resizeTo(width, height)
window.resizeTo(width, height)
window.resizeBy(x, y)
window.resizeBy(x, y)
Important notes:
重要笔记:
- You can't resize a window or tab that wasn't created by window.open.
- You can't resize a window or tab when it's in a window with more than one tab.
- Also, even if you create window by
window.open(...)
it is not resizable by default ...see 4. - To make window created by
window.open()
resizable, you must open it with resizable feature
- 您无法调整不是由 window.open 创建的窗口或选项卡的大小。
- 当窗口或选项卡位于具有多个选项卡的窗口中时,您无法调整窗口或选项卡的大小。
- 此外,即使您通过它创建窗口
window.open(...)
,默认情况下也不能调整大小...参见 4。 - 要通过
window.open()
可调整大小创建窗口,您必须使用可调整大小功能打开它
Example of how to create external window with "resizable" feature:
如何使用“可调整大小”功能创建外部窗口的示例:
myExternalWindow = window.open("http://myurl.domain", "myWindowName", "resizable");
myExternalWindow.resizeTo(500,500); //resize window to 500x500
myExternalWindow.resizeBy(-100,-100); //make it smaller relatively => to 400x400
PS: There are also browser extensions that allow window resizing... (Chrome)(Mozilla Firefox)
PS:也有允许调整窗口大小的浏览器扩展...(Chrome)(Mozilla Firefox)
PS2:Chrome extension API - https://developer.chrome.com/extensions/windows
PS2:Chrome 扩展 API - https://developer.chrome.com/extensions/windows
回答by Naveed Butt
This is because it is not supported in Opera and Chrome...
这是因为 Opera 和 Chrome 不支持它...
http://www.w3schools.com/jsref/met_win_resizeto.asp
http://www.w3schools.com/jsref/met_win_resizeto.asp
UPDATE:
更新:
This might help you in finding something specific to what you want...
这可能会帮助您找到特定于您想要的东西......
http://bytes.com/topic/javascript/answers/153185-moveto-resize-firefox
http://bytes.com/topic/javascript/answers/153185-moveto-resize-firefox
回答by Alpine
Note: There is no public standard that applies to the Window object, but all major browsers support it.
注意:没有适用于 Window 对象的公共标准,但所有主要浏览器都支持它。
The window.resizeTo()
and window.resizeBy()
methods are supported in all major browsers, except Opera and Chrome.
该window.resizeTo()
和window.resizeBy()
方法在所有主流浏览器的支持,除了Opera和Chrome浏览器。