Window name attribute

Definition and Usage

name Sets or returns the name of the window.

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

Instance

Example 1

Get the window name:

let name = window.name;

Try it yourself

Example 2

Set the 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

Syntax

Return the name attribute:

window.name

Set the 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.

Returns if the window has no name 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