Javascript Browser Window open() Method replace current window with a new window

Introduction

Replace the current window with a new window:

Click the button to put the new window in the current window.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>
<script>
function myFunction() {/*  w  ww.  j a va  2s .c  o  m*/
  var myWindow = window.open("", "_self");
  myWindow.document.write("<p>I replaced the current window.</p>");
}
</script>
</body>
</html>



PreviousNext

Related