Repositioning a Window


window.moveBy(-10, 10); 

When opening a new window, you have to take all browsers into account: For Internet Explorer, set the left and top options; all other browsers work with screenX and screenY. The following window.open() call creates a window in the top-left corner of the screen.

window.open(   "anypage.html",   "name",   "left=0,top=0,screenX=0,screenY=0"); 


However, for existing windows, two methods that are quite similar to the previous phrase come into play:

  • moveTo() positions the window at the specified place, as the code at the beginning of this phrase (in file moveto.html) shows.

  • moveBy() moves the window by a certain delta. The following listing moves the window 10 pixels to the left and 10 pixels down.

Moving a Window (moveby.html)

<script language="JavaScript"   type="text/javascript"> window.moveBy(-10, 10); </script> 

Warning

Moving a window is almost as unfriendly as resizing it, so once again, use this capability wisely. Also note that you cannot move the window completely out of the user's sight, for obvious security reasons.





JavaScript Phrasebook(c) Essential Code and Commands
JavaScript Phrasebook
ISBN: 0672328801
EAN: 2147483647
Year: 2006
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net