Window.name

Gets/sets the name of the window's browsing context.

Syntax

string = window.name;
window.name = string;

Example

<script>
    // Open a tab with a specific browsing context name
    const otherTab = window.open("url1", "_blank");
    if (otherTab)
        otherTab.name = "other-tab";
</script>
<a href="url2" target="other-tab">This link will be opened in the other tab.</a>

Notes

The name of the window is used primarily for setting targets for hyperlinks and forms. Browsing contexts do not need to have names.

It has also been used in some frameworks for providing cross-domain messaging (e.g., SessionVars and Dojo's dojox.io.windowName) as a more secure alternative to JSONP. Modern web applications hosting sensitive data should, however, not rely on window.name for cross-domain messaging but instead utilize the postMessage API.

window.name will convert all values to their string representations by using the toString method.

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'Window.name' in that specification.
Living Standard
HTML5
The definition of 'Window.name' in that specification.
Recommendation

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
nameChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support
Full support
Compatibility unknown
Compatibility unknown