The syntax of the window.open method is given below:
open (URL, windowName[, windowFeatures])
URL The URL of the page to open in the new window. This argument could be blank.
windowName A name to be given to the new window. The name can be used to refer this window again.
windowFeatures A string that determines the various window features to be included in the popup window (like status bar, address bar etc) The following code opens a new browser window with standard features.
Changing the features of the Popup
You can control the features of the popup using the last argument to the window.open method. The following code opens a window with a status bar and no extra features.
The code below opens a window with toolbar and status bar.
The table shows the features and the string tokens you can use:
The status bar at the bottom of the window.
The standard browser toolbar, with buttons such as Back and Forward.
The Location entry field where you enter the URL.
The menu bar of the window
The standard browser directory buttons, such as What’s New and What’s Cool
Allow/Disallow the user to resize the window.
Enable the scrollbars if the document is bigger than the window
Specifies the height of the window in pixels. (example: height=’350’)
Specifies the width of the window in pixels.
The following code opens a window with menu bar. The window is re-sizable and is having 350 pixels width and 250 pixels height.
A window with location bar, status bar, scroll bar and of size 100 X 100
Moving the window to a desired location
You can use the window.moveTo function to move the popup window to a desired location. The code below shows positioning the popup at a desired location.
The code positions the popup on the top left corner of the screen.
Putting it all together
Now we will combine all these information to create the popup windows of different types. The Code below opens a popup window when you enter the page:
The code contains an extra line:
This code displays a line ‘Popup Test!’ in the popup.