Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
370 views
in Technique[技术] by (71.8m points)

javascript - window.resize is not working in chrome and opera

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...