- Let’s consider the new document as a string.
- Use the
.open()method which takes two parameters (first is “text/html” and second is “replace”).
- If we don’t use the ‘replace’ then method will call adds page history. So we would have to click back two times to go to the previous page. So, replace is necessary argument to pass.
- To this new document use
.write()method and pass the new document.
- Now at last use
.close()method on the document for it to work.
var newHTMLStr =
'Clue Mediator</title></head><body style="text-align:center;">'+
'<h2 style="color: #269faf;">Clue Mediator</h2><p>'+
'The way to write your code</p></body> </html>';
var newHTML = document.open("text/html", "replace");
That’s it for today.
Thank you for reading. Happy Coding..!! 🙂