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

Eigenschaftswert

Eigenschaftswert Beschreibung
winName der Name des Fensters.

Rückgabewert

Typ Beschreibung
Zeichenkette

der Name des Fensters.

Wird der Name des Fensters nicht zurückgegeben, wenn view.

Browserunterstützung

Unterstützt von allen Browsern window.name:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Unterstützt Unterstützt Unterstützt Unterstützt Unterstützt Unterstützt