JavaScript Program to Create a New Window and Write some text on Newly Created Window

Write a JavaScript program to create a new window and Write some text on newly created window.



Source Code
<html>
<head>
    <title>Write some text on newly created window</title>
    <script>
        function createNewWindow() 
        {
            var win = window.open("", "MyWindow", "width=300, height=200")
            win.document.write("<h1>I am newly created window</h1>")
        }
    </script>
</head>

<body>
<form name="myform">
    <input type="button" value="Create New Window" onclick="createNewWindow()"/>
</form>
</body>

</html>
Output