English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Window name attribute

JavaScript Window Object

nameSet or return the window name attribute.

After creating a window, this property is usually used to modify the window name.

The window name is mainly used to set the target of hyperlinks and forms. Windows do not need a name.

Syntax:

Return name attribute:

window.name

Set Name Property:

window.name = string
var win = window.open("", "popupWindow", "width=300, height=200");
win.document.write("<p>This window"39;s name is: " + win.name + "</p>
Test and See‹/›

Browser Compatibility

All browsers fully support the name property:

Property
nameYesYesYesYesYes

Property Value

ValueDescription
stringSpecify the window name

Technical Details

Return Value:A string representing the window name

More Examples

Set the name of the current window to "myWindow":

window.name = "myWindow";
Test and See‹/›

Related References

Window (Window) Reference:window.open() method

Window (Window) Reference:window.close() method

JavaScript Window Object