Window name Property - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window name

Description

The name property sets or gets the name of the window.

Set the name property with the following Values

Value Type Description
winName String Sets the name of the window

Return Value

A String, representing the name of the window.

If the name is not specified, this property returns "view"

The following code shows how to create a window with the open() method, and return the name of the new window:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/* w w w .j  a  v a 2  s  .  c  o  m*/
    window.name = "myWindowName";
    var x = "This window's name is now: " + window.name;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials