PDA

View Full Version : JS password gate question


sessomy
06-30-2003, 02:38 AM
Hi

I'm really new to js programming, so forgive me if this is basic.
I wanted to put a password gate on a page and have found this one:

To go in head section:

<script language="JavaScript">

function PasswordLogin()
{
document.location.href = document.formlogin.password.value + ".htm";
return false;
}


function CheckEnter(event)
{
var NS4 = (document.layers) ? true : false;
var code = 0;

if (NS4)
code = event.which;
else
code = event.keyCode;
if (code==13)
{
PasswordLogin();
event.returnValue = false;
}
}

</script>


To go in body:

<form name="formlogin" onsubmit="PasswordLogin()">
Password: <input type="password" name="password" size="20" onKeyPress="CheckEnter(event)">
<input type="button" value="Login" onclick="PasswordLogin()"></p>
</form>


My question is can anyone tell me how to change this code so that the passworded page opens in a new window!!!?

Its the first time I've tryed the script...... does anyone know of any better ones???

Thanks
Stuart

A1ien51
06-30-2003, 06:56 AM
change
document.location.href = document.formlogin.password.value + ".htm";

to

WinPop = window.open(document.formlogin.password.value + ".htm");

Eric

sessomy
06-30-2003, 11:29 AM
Thanks Eric.....

That works, but unfortunately the original page.... the one with the script on becomes a HTTP 404 not found page, and the url in the address bar says http://www.mysite.org/[object]

Any more help.... I do want the rest of the site to stay underneath the popup..... that was the whole idea. :)

Thanks

Stuart

A1ien51
06-30-2003, 03:49 PM
<form name="formlogin" onsubmit="PasswordLogin()">

to
<form name="formlogin" onsubmit="return PasswordLogin()">

sessomy
06-30-2003, 03:56 PM
Mmm...... it's stiill doing it!!!

:(

A1ien51
06-30-2003, 04:03 PM
just chop it to this

<form name="formlogin">

see if that works and get rid of the return false in the function

sessomy
06-30-2003, 04:13 PM
It's still doing it!!!!:confused:

kansel
06-30-2003, 04:48 PM
try

<form name="formlogin" action="#" onsubmit="PasswordLogin();return false">

sessomy
06-30-2003, 05:22 PM
No..... it's still doing the same.

Is this a tricky one???

:)

S x

arnyinc
06-30-2003, 05:58 PM
Originally posted by sessomy
No..... it's still doing the same.

Is this a tricky one???

:)

S x

What browser are you using? Is that all the script and html code that is on the page?

The code on this page works perfectly fine for me in IE, Mozilla, and Opera.

sessomy
06-30-2003, 06:18 PM
I've got IE 6.0.

The password gate is fine in itself but after I put the code in to make the password protected page popup in a seperate window
the original page goes to a HTTP 404 not found page.

It may just be my browser.....

Seem's strange though.

S x

sessomy
07-01-2003, 07:02 PM
Right.... ok.

Can anyone suggest another simple password gate script?

Preferably I want username and password funtions and the password protected page to open in a new window.

Ta

Stuart