Minggu, 03 Januari 2010

Open Link in New Window and Resize It

If you completed the assignments in the previous session you know how to open new windows. Like the alert() method, the open() also takes arguments. When used without any arguments, the new window displayed is blank. Here I tell you how to embellish this new window.

<A HREF="javascript:void(0)"

onclick="window.open('welcome.html')">

Open a new window</A>

Open a new window

This opens a new window with welcome.html page.

The arguments of JavaScript open()

The open() method takes four arguments:

window.open('URL', 'NAME', 'FEATURES', 'REPLACE')

We have already seen that if we provide the URL of a document through the first argument, it will be loaded in the new window.

NAME: specifies a name for the new window that can then be used as value for the TARGET attribute of <A> tags.

FEATURES: let you define properties of the window such as width, height, presence or absence of scrollbars, location bar, stauts bar etc. The list of features is quite daunting so we shall go over them gradually.

REPLACE: takes a boolean value... we won't bother ourselves with this argument!

<A HREF="javascript:void(0)"

onclick="window.open('welcome.html','welcome')">

Open a new window</A>

Open a new window



Tidak ada komentar: