You are here: irt.org | FAQ | JavaScript | Form | Q1673 [ previous next ]
Try:
<script language="JavaScript"><!-- var userid = ''; var password = ''; var windowReference; function promptForTwo() { var w = 480, h = 340; if (window.screen) { w = screen.availWidth; h = screen.availHeight; } var popW = 300, popH = 150; var leftPos = (w-popW)/2, topPos = (h-popH)/2; window.open('popup.htm','windowName','width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos); if (!windowReference.opener) windowReference.opener = self; } function done() { locattion.href = 'http://' + userid + ':' + password + '@www.yourserver.com/index.htm'; } promptForTwo(); //--></script>
And then in popup.htm:
<html> <head> <script language="JavaScript"><!-- function prompts(form) { opener.userid = form.userid.value; opener.password = form.password.value; opener.done(); self.close(); return false; } function cancel() { self.close(); return false; } //--></script> </head> <body onLoad="document.myform.userid.focus()"> <form name="myForm" onSubmit="return prompts(this)" onReset="cancel()"> Userid: <input type="text" name="userid"> <br> Password: <input type="password" name="password"> <br> <input type="submit" value=" ok "> <input type="reset" value=" cancel "> </form> </body> </html>