The object window has different methods, properties and event handlers in JavaScript. Here are a few examples : Opening a new window : The window.open() method gives the web designer control over the look and appearance of the second or third window. The best way to explain someting is through an example, so here is one with a link : <a href="#" onclick="window.open('somepage.html','')">link</a> . This would open a normal new window. The two parameters between the brackets and within single quotes are needed in order for the script to work, though the second parameter (the name of the window) can be, and usually is, left blank. There is also an optional third attributes parameter, which actually defines the look and appearance of the new window. The attributes are : width, height, scrollbars , location, status, menubar etc. If you define only one attribute here, all the others will be left out. Example : <a href="#" onclick="window.open('somepage.html','','width=250, height=250,scrollbars')">Click here</a> . To see the example click here. Closing a window : To close a window with a link or button from inside the window, use the method window.close(). See the previous window example.
Resizing a window : To resize a window, write the following in the href tag <a href="javascript:window.resizeTo(640,480)">. Example : if you click here , your Browser-window will be resized to 640 x 480 . To resize the Browser-window to the full size just click here .
N e x t
|