DelphiFAQ Home Search:

Reference: window.open to pop up a browser window

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

window.open(URL, name [, features])

This method is used to open a new browser window. Note that, when using this method with event handlers, you must use the syntax window.open() as opposed to just open(). Calling just open() will, because of the scoping of static objects in JavaScript, create a new document (equivalent to document.open()), not a window.
Sometimes you may want to open the new window in 'maximized' mode. You can not do that with Mozilla browsers. The philosophy is to try to make the opening of new secondary windows noticed by users to avoid confusion.

The available parameters are as follows:

  1. URL - this is a string containing the URL of the document to open in the new window. If no URL is specified, an empty window will be created.
  2. name - this is a string containing the name of the new window. This can be used as the 'target' attribute of a
    or tag to point to the new window.
  3. features - this is an optional string that contains details of which of the standard window features are to be used with the new window. This takes the form of a comma-delimited list. Most of these features require yes or no (1 or 0 is also o.k.) and any of these can be turned on by simply listing the feature (they default to yes). Also, if you don't supply any of the feature arguments, all features with a choice of yes or no are enabled; if you do specify any feature parameters, titlebar and hotkeys still default to yes but all others are no.

Note that many of the values for the features parameter are Netscape only. Further, with the exception of dependent and hotkey, these Netscape only values represent potential sources of security problems and therefore require signed script (and user's permission) if they are to be used.

Details of the available values are given below:

features Value Description
alwaysLowered [Netscape] When set to yes, this creates a window that always floats below other windows.
alwaysRaised [Netscape] When set to yes, this creates a window that always floats above other windows.
dependent [Netscape] When set to yes, the new window is created as a child (closes when the parent window closes and does not appear on the task bar on Windows platforms) of the current window.
directories When set to yes, the new browser window has the standard directory buttons.
height This sets the height of the new window in pixels.
hotkeys [Netscape] When set to no, this disables the use of hotkeys (except security and quit hotkeys) in a window without a menubar.
innerHeight [Netscape] This sets the inner height of the window in pixels.
innerWidth [Netscape] This sets the inner width of the window in pixels.
location When set to yes, this creates the standard Location entry feild in the new browser window.
menubar When set to yes, this creates a new browser window with the standard menu bar (File, Edit, View, etc.).
outerHeight [Netscape] This sets the outer height of the new window in pixels.
outerWidth [Netscape] This sets the outer width of the new window in pixels.
resizable When set to yes this allows the resizing of the new window by the user.
screenX [Netscape] This allows a new window to be created at a specified number of pixels from the left side of the screen.
screenY [Netscape] This allows a new window to be created at a specified number of pixels from the top of the screen.
scrollbars When set to yes the new window is created with the standard horizontal and vertical scrollbars, where needed
status When set to yes, the new window will have the standard browser status bar at the bottom.
titlebar [Netscape] When set to yes the new browser window will have the standard title bar.
toolbar When set to yes the new window will have the standard browser tool bar (Back, Forward, etc.).
width This sets the width of the new window in pixels.
z-lock [Netscape] When set to yes this prevents the new window from rising above other windows when it is made active (given focus).


These features may only be used with IE4:

channelmode sets if the window appears in channel mode.
fullscreen the new window will appear in full screen.
left same as screenX, allows a new window to be created at a specified number of pixels from the left side of the screen.
top same as screenY, allows a new window to be created at a specified number of pixels from the top of the screen.

myWindow = window.open("", "tinyWindow", 'toolbar,width=150,height=100') 
myWindow.document.write("Welcome to this new window!")
myWindow.document.bgColor="lightblue"
myWindow.document.close() 

Comments:

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: