Set the name of the current window to myWindowName
:
window.name = "myWindowName";
Click the button to set the name of the window to myWindowName
.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//w w w . jav a 2 s .com window.name = "myWindowName"; var x = "This window's name is now: " + window.name; document.getElementById("demo").innerHTML = x; } </script> </body> </html>