Javascript Reference
Categories: window

javascript window open( )

@July 16, 2008, 3:56 a.m.
open( ) Firefox/Netscape/NN 2 IE 3 Chrome/Safari/DOM n/a  
open("URL", "windowName"[, "windowFeatures"])
open("URL", "windowName"[, "windowFeatures"][, replaceFlag])

Opens a new window (without closing the original one). You can specify a URL to load into the new window or set that parameter to an empty string to allow scripts to document.write( ) into that new window. The windowName parameter lets you assign a name that can be used by target attributes of link and form elements. This name is not to be used in script references as frame names are. Instead, a script reference to a subwindow must be to the window object returned by the window.open( ) method. Therefore, if your scripts must communicate with a window opened in this manner, it is best to save the returned value as a global variable so that future statements can use it.

A potential problem with subwindows is that they can be buried under the main window if the user clicks on the main window (or a script gives it focus). Any script that opens a subwindow should also include a focus( ) method for the subwindow (in Navigator 3 and later, and in IE 4 and later) to make sure it comes to the front in case it is already open. Subsequent invocations of the window.open( ) method in which the windowName parameter is the same as an earlier call automatically address the previously opened window, even if it is underneath the main window (and thus without bringing the window to the front).

The optional third parameter gives you control over various physical attributes of the subwindow. The windowFeatures parameter is a single string consisting of a comma-delimited list (without spaces between items) of attribute/value pairs:

newWindow = window.open("someDoc.html","subWind",
"status,menubar,height=400,width=300");
newWindow.focus( );

By default, all window attributes are turned on and the subwindow opens to the same size that the browser would use to open a new window from the File menu. But if your script specifies even one attribute, all settings are turned off. Therefore, use the windowFeatures parameter to specify those features that you want turned on.

If you encounter problems referencing a subwindow immediately after it is created, the problem is most likely a timing issue (affecting IE for Windows more than others). Script statements seem to want to reference the window before it exists completely. To work around the problem, place the code that works with the subwindow in a separate function, and invoke that function via the setTimeout( ) method, usually with no more than 50 milliseconds needed.

Managing multiple windows through scripts can be difficult. Security restrictions across domains frequently foil the best intentions. Users aren't always fond of windows appearing and hiding on their own. If your audience uses newer browsers, consider simulating windows with positioned elements.

 
Parameters
 
Attribute Firefox/Netscape/NN IE Description
alwaysLowered 4 n/a Always behind all other browser windows. Signed script required.
alwaysRaised 4 n/a Always in front of all other browser windows. Signed script required.
channelMode n/a 4 Show in theater mode with channel band.
copyhistory 2 3 Copy history listing from opening window to new window.
dependent 4 n/a Subwindow closes if the window that opened it closes.
directories 2 3 Display directory buttons.
fullscreen n/a 4 Display no titlebar or menus
height 2 3 Window height in pixels.
hotkeys 4 n/a Disables menu keyboard shortcuts (except Quit and Security Info).
innerHeight 4 n/a Content region height. Signed script required for very small measures.
innerWidth 4 n/a Content region width. Signed script required for very small measures.
left 6 4 Offset of window's left edge from left edge of screen.
location 2 3 Display Location (or Address) text field.
menubar 2 3 Display menubar (a menubar is always visible on Mac).
outerHeight 4 n/a Total window height. Signed script required for very small measures.
outerWidth 4 n/a Total window width. Signed script required for very small measures.
resizable 2 3 Allow window resizing (always allowed on Mac).
screenX 4 n/a Offset of window's left edge from left edge of screen. Signed script required to move window offscreen.
screenY 4 n/a Offset of window's top edge from top edge of screen. Signed script required to move window offscreen.
scrollbars 2 3 Display scrollbars if document is too large for window.
status 2 3 Display status bar.
titlebar 4 n/a Displays titlebar. Set this value to no to hide the titlebar. Signed script required.
toolbar 2 3 Display toolbar (with Back, Forward, and other buttons).
top 6 4 Offset of window's top edge from top edge of screen.
width 2 3 Window width in pixels.
z-lock 4 n/a New window is fixed below browser windows. Signed script required.
 
  • A complete or relative URL as a string. If an empty string, no document loads into the window.
  • An identifier for the window to be used by target attributes. This is different from the title attribute of the document that loads into the window.
  • A string of comma-delimited features to be turned on in the new window. Do not put spaces after the comma delimiters. The list of possible features is long, but a number of them are specific to Navigator 4 or later and require signed scripts because they are potentially a privacy and security concern to unsuspecting users. The features are listed as follows. To turn on a window feature, simply include its case-insensitive name in the comma-separated list. Only attributes specifying dimensions require values be assigned.
 
  • Boolean value (for IE only) that controls the effect of the new window's URL on the global history of the browser. Set to true to replace the current page with the new window's URL (so that the current page won't be accessed through the Back button); set to false to add the new window's URL to the history, as normal.
 
Returned Value

Window object reference.

buy atorvastatin 40mg without prescription <a href="https://lipiws.top/">oral atorvastatin 20mg</a> buy atorvastatin online cheap
Ialqsq - 1 weeks

Powered by Linode.