You are here: Reference > JavaScript > client-side > HTML DOM > properties > name (window)

name property (window)

Browser support:
Sets or retrieves the name of the current window object, which is used to identify the window.
With the name property, the name of a window can be modified, after the window has been created. It is also possible to specify the initial name of a newly created window.
  • When a window is opened by an anchor, then the target property specifies the initial name of the created window. For details, see Example 1 or the page for the target property.
  • When a window belongs to a frame or iframe element, then the name property sets the initial name of the contained window. See Example 2 for details.
  • Finally, if a window is created dynamically by the open method, then the second parameter of the method specifies the initial name of the created window. See Example 3 for details.
The name of windows can be used to identify them. When a new window needs to be opened with a specified name and a window opened by the current document already exists with the same name, then the browser uses the existing window instead of creating a new one.

You can find the related objects in the Supported by objects section below.
This property is read/write.

Possible values:

String that specifies or retrieves the name of the window.
Default: this property has no default value.

Example HTML code 1:

This example shows how to create named windows with anchor elements:
<a href="nameTest.htm" target="myWindow">Open a new window, with the name of myWindow!</a>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates named windows inside iframe objects:
<iframe name="TargetFrame" src="nameTest.htm" height="150" width="200"></iframe>
Did you find this example helpful? yes no

Example HTML code 3:

This example illustrates the use of the open method for creating named windows:
    <script type="text/javascript">
        function OpenChildWindow () {
            var childWindow = ("nameTest.htm", "myWindow", "width=200,height=200", null);           
    <button onclick="OpenChildWindow ()">Open child window with name of myWindow!</button><br />
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content