Opening a New Window in a Corner of the Screen


newwin.moveTo(   screenwidth - windowwidth,   screenheight - windowheight); 

Opening a window in the top-left corner of the screen is rather easy: Just provide 0 as the horizontal and vertical position:

Opening a Window in the Top-Left Corner (open_topleft.html)

[View full width]

<script language="JavaScript"   type="text/javascript"> var newwin = window.open(   "http://www.samspublishing.com/",   "samsWindow",   "width=640,height=480,directories=no,menubar=no, toolbar=no,scrollbars=yes,left=0,top=0 ,screenX=0, screenY=0"); </script> 

All other corners on the screen are a bit more difficult since you have to calculate the positions. Thanks to the screen object, this dilemma can be solved with a small amount of code. The following code positions the new window in the bottom-left corner; listings for the other two corners are available in the files open_topright.html and open_bottomleft.html.

Opening a Window in the Bottom-Right Corner (open_bottomright.html)

<script language="JavaScript"   type="text/javascript"> var newwin = window.open(   "http://www.samspublishing.com/",   "samsWindow",   "width=640,height=480,directories=no,menubar=no, toolbar=no,scrollbars=yes"); var windowwidth = 640; var windowheight = 480; var screenwidth = screen.availWidth; var screenheight = screen.availHeight; newwin.moveTo(   screenwidth - windowwidth,   screenheight - windowheight); </script> 




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