Javascript Browser Window open() Method open a window and get its name

Introduction

Open a new window. Use the name property to return the name of the new window:

Click the button to create a window and then display the name of the new window.

View in separate window

<!DOCTYPE html>
<html>
<body>


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

<script>
function myFunction() {//from www  .  ja  va2 s.c  om
  var myWindow = window.open("", "MsgWindow", "width=200,height=100");
  myWindow.document.write("<p>This window's name is: " + myWindow.name + "</p>");
}
</script>

</body>
</html>



PreviousNext

Related