Java Reference
In-Depth Information
Controlling Windows
A new window can be opened using the window.open() method. This takes the URL of
the page to be opened as its first parameter, and a list of attributes as the second parameter.
This can also be assigned to a variable, so the window can then be referenced later in the
code:
popup =
window.open('https://sitepoint.com','SitePoint','width=400,
height=400,resizable=yes');
The window.close() method can be used to close a window:
popup.close();
It is also possible to move a window using the window.move() method. This takes two
parameters that are the X and Y coordinates of the screen that the window is to be moved to:
window.moveTo(0,0); // will move the window to the top-left
corner
of the screen
You can resize a window using the window.resizeTo() method. This takes two para-
meters that specify the width and height of the resized window's dimensions:
window.resizeTo(600,400);
Warning: Avoid Popups!
These methods were largely responsible for giving JavaScript a bad name as
they were used for creating annoying pop-up windows. It's also a bad idea
from a usability standpoint to resize or move a user's window.
Many browsers block pop-up windows and disallow some of these methods
to be called in certain cases. For example, you can't resize a window if more
than one tab is open.
Search WWH ::




Custom Search