Document.write() example

Example of using document.write()

by Vaibhav Vishal

HTML

<html>
<script>
	function replace(){
const newhtml = '<html><body style="background-color: white"><p>New Content</p></body></html>';
document.open()
document.write(newhtml);
document.close();
}
</script>
<body>
<p>
Old Content
</p>
<a href='javascript:replace()'>Replace</a>
</body>
</html>