JavaScript Program to Create and Close Newly Created Window

Write a JavaScript program to create and close newly created window.



Source Code
<html>
<head>
    <title>Create and Close window</title>
    <script>
        var win
        function createWindow() 
        {
            win = window.open("", "MyWindow", "width=300, height=200, toolbar=1")
        }
        function closeWindow() 
        {
            win.close()
        }
    </script>
</head>

<body>
<form name="myform">
    <input type="button" value="Create Window" onclick="createWindow()"/>
    <input type="button" value="Close Window" onclick="closeWindow()"/>
</form>
</body>

</html>
Output