JavaScript Program to Create User Login Form on Newly Created Window

Write a JavaScript program to create user login form on newly created window.



Source Code
<html>
<head>
    <title>Create user login form on newly created window</title>
    <script>
        function createWebPage() 
        {
            var mywin = window.open('', 'myWindow', 'width=300, height=200');
            mywin.document.write('<html>');
            mywin.document.write('<head>');
            mywin.document.write('<title>Web Page newly created</title>');
            mywin.document.write('</head>');
            mywin.document.write('<body>');
            mywin.document.write('<h1>User Login Form</h1>');
            mywin.document.write('<form action="" method="post">');
            mywin.document.write('User name <input type="text" name="uname"/><br/>');
            mywin.document.write('Password <input type="password" name="pwd"/><br/>');
            mywin.document.write('<input type="submit" value="SUBMIT"/><br/>');
            mywin.document.write('</form>');
            mywin.document.write('</body>');
            mywin.document.write('</html>');
        }
    </script>
</head>

<body>
<form>
    <input type="button" value="Create Web Page" onclick="createWebPage()"/>
</form>
</body>

</html>
Output