The document.open() method opens a new document, writes its contents in the document.write() method, and then closes the document with the document.close() method to make its contents appear.
Such as:
<script type="text/javascript">
window.onload=hello;
function hello(){
var msg = "JavaScript This is fun! ";
document.open();
document.write(msg);
document.close();
}
</script>