Using document.write() on the Current Window
<html> <head> <title>Writing to Same Doc</title> <script type="text/javascript"> function reWrite() { var newContent = "<html><head><title>title</title></head>"; newContent += "<body bgcolor='aqua'><h1>This document is brand new.</h1>"; newContent += "Click the Back button to see original document."; newContent += "</body></html>"; document.write(newContent); document.close(); } </script> </head> <body> <form> <input type="button" value="Replace Content" onclick="reWrite()"> </form> </body> </html>