Sunday, February 22, 2009

Javascript Parent Child window / window.open method / Open PopUp window

Do you want to open PopUp window from your current window. It can open by using javascript's window.open method. The new opened window is called the Child window and from which window you have open it is called Parent window.

The syntax of window.open is as follows:

open (URL, windowName[, windowFeatures])

Where URL is the url of the page which you want to open.
windowname is a name given to the new window
windowFeatures is the string which can include status bar, address bar etc.. window features will be included in the new popup window.

For example:
window.open ("http://vijaymodi.wordpress.com","Vijay Modi's Blog");

will opens a new browser window with standard features.

To open a window with statusbar and toolbar you have to write the following code:
window.open ("http://vijaymodi.wordpress.com","Vijay Modi's Blog","status=1,toolbar=1");

The following table shows the features and the string tokens you can use in the features depends on your requirements:
status The status bar at the bottom of the window.
toolbar The standard browser toolbar, with buttons such as Back and Forward.
location The Location entry field where you enter the URL.
menubar The menu bar of the window
directories The standard browser directory buttons, such as What's New and What's Cool
resizable Allow/Disallow the user to resize the window.
scrollbars Enable the scrollbars if the document is bigger than the window
height Specifies the height of the window in pixels. (example: height='350')
width Specifies the width of the window in pixels.

Regards,
Vijay Modi

No comments:

Post a Comment