Window.name (Property)

The name of the window either from the <FRAME> tag, the Window.open() method call or an assignment to this property.

Availability:

DOM level - 1
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Opera - 3.0
Property/method value type:String primitive
JavaScript syntax:-myWindow.name
-myWindow.name = aString
-name
-name = aString
-window.open(aURL, aName, ...)
HTML syntax:<FRAME NAME="..."> Window.open(...)
Argument list:aNameA name for the window
aStringA string value containing the new name for the window
aURLA URL to load into the window

This name value can be used with the target attribute of the HTML <A> anchor tag or the <FORM> tag.

At version 1.0 of JavaScript this is a read-only property.

JavaScript version 1.1 introduces the capability of changing the name of a window and makes this property writable. This is particularly useful because the initial window has no name and cannot be targeted directly until it has. You can fix this with an onLoad handler.

The name of a window can be set when the window is created with the open() method. It is also assigned by the NAME="..." HTML tag attribute of a <FRAME> tag.

The example shows the window name being modified. Reload to see the persistence effect. Load another document and then load this script again to see how the name persists through intermediate document loads.

Warnings:

Example code:

   <HTML>

   <HEAD>

   </HEAD>

   <BODY>

   <SCRIPT>

   document.write("***"+window.name+"<BR>");

   window.name = "FRED";

   document.write("***"+window.name+"<BR>");

   </SCRIPT>

   </BODY>

   </HTML>

See also:Frame object, IFRAME.name, NAME="...", Window object, Window.open()