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
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
name | Chrome Full support Yes | Edge Full support 12 | Firefox Full support Yes | IE ? | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- Compatibility unknown
- Compatibility unknown