Window nameProperty
Window Object
Definition and Usage
The name property sets or returns a string that stores the name of the window.
Syntax
window.name
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the name property.
Example
Example
Return the name of the new window:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
var myWindow;
function openWin(){
myWindow=window.open('','MsgWindow','width=200,height=100');
myWindow.document.write("<p>The window name is: " + myWindow.name + "</p>");
}
</script>
</head>
<body>
<input type="button" value="Open my window" onclick="openWin()" />
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
var myWindow;
function openWin(){
myWindow=window.open('','MsgWindow','width=200,height=100');
myWindow.document.write("<p>The window name is: " + myWindow.name + "</p>");
}
</script>
</head>
<body>
<input type="button" value="Open my window" onclick="openWin()" />
</body>
</html>
Try it Yourself »
Window Object Other Extensions