window.resize is not working in chrome and opera

痴心易碎 提交于 2019-11-27 04:34:29

问题


window.resize is not working in chrome and opera ..how to make it work?


回答1:


There is no window.resize()

...however...

There are:

window.resizeTo(width, height)

window.resizeBy(x, y)

Important notes:

  1. You can't resize a window or tab that wasn’t created by window.open.
  2. You can't resize a window or tab when it’s in a window with more than one tab.
  3. Also, even if you create window by window.open(...) it is not resizable by default ...see 4.
  4. To make window created by window.open() resizable, you must open it with resizable feature

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)

PS2: Chrome extension API - https://developer.chrome.com/extensions/windows




回答2:


This is because it is not supported in Opera and Chrome...

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




回答3:


Note: There is no public standard that applies to the Window object, but all major browsers support it.

The window.resizeTo() and window.resizeBy() methods are supported in all major browsers, except Opera and Chrome.

refer
Window resizeTo() Method
Window resizeBy() Method



来源:https://stackoverflow.com/questions/5139323/window-resize-is-not-working-in-chrome-and-opera

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!