Window name attribute

Definition and usage

name Set or return the name of the window attribute.

Hint:The window does not need to have a name.

Instance

Example 1

Get window name:

let name = window.name;

Try it yourself

Example 2

Set window name:

window.name = "myWindowName";

Try it yourself

Example 3

Open a frame with a special name:

const otherWindow = window.open();
otherWindow.name = "Butterfly";

Try it yourself

Grammar

Return name attribute:

window.name

Sedate name attribute:

window.name = winName

Attribute value

Attribute value Description
winName The name of the window.

Return value

Type Description
String

The name of the window.

If the window has no name, it returns view

Browser support

All browsers support window.name

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support