Objectives and outcomes

In this tutorial we are going to learn about window object model how to use it to open a new window and add content to the created new window. example for the same is shown below:





Create a button in html and attach the following javascript to it



Javascript:

<script>
function new_win()
{
var win = window.open();
win.document.open();
win.document.write("<h1>Window object in javascript</h1>");
win.document.close();
}
</script>


In the new_win() function first we created a new browser window the a document is created using document.open function and then the required html is attached to the document created by using document.write function.