Replace the current window with a new window:
Click the button to put the new window in the current 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>