Window name Property
Example
Create a window with the open() method, and return the name of the new window:
var myWindow = window.open("", "MsgWindow", "width = 200, height = 100");
myWindow.document.write("<p>This window's name is: " + myWindow.name + "</p>");
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The name property sets or returns the name of the window.
This property is often used to modify the name of a window, after the window has been created.
Note: The name of the window is often used for setting targets for hyperlinks and forms. However, this is not required, as windows do not need to have names.
Browser Support
Property | |||||
---|---|---|---|---|---|
name | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the name property:
window.name
Set the name property:
window.name=winName
Property Values
Value | Type | Description |
---|---|---|
winName | String | Specifies the name of the window |
Technical Details
Return Value: | A String, representing the name of the window. Note: If the name is not specified, this property returns "view" |
---|
More Examples
Example
Set the name of the current window to "myWindowName":
window.name = "myWindowName";
Try it Yourself »
Window Object