<html> <head> <script type="text/javascript"> function createNewDoc() { var newDoc=document.open("text/html","replace"); var txt="<html><body>Learning about the DOM is FUN!</body></html>"; newDoc.write(txt); newDoc.close(); } </script> </head> <body> <input type="button" value="Open and write to a new document" onclick="createNewDoc()"> </body> </html>
Your Result:
Edit the code above and click to see the result.
W3Schools.com
- Try it yourself