Hi, i'm trying to write a web page that
will prompt for a password, go to a specific page if correct, but if not then go to a default apge...the code i'm using is below..
<HTML>
<HEAD>
<TITLE>My Page</TITLE>
<SCRIPT language="JavaScript"><!--
function GateKeeper()
{
var password = prompt("Password required:", "");
if (password) { this.location.href = <!-- m --><a class="postlink" href="http://www.htmlforums.com/archive/index.php/password">http://www.htmlforums.com/archive/index.php/password</a><!-- m --> + ".html"; }}
//--></SCRIPT>
</HEAD>
<BODY>
<A HREF=http://www.htmlforums.com/archive/index.php/"javascript:{;}" onClick="GateKeeper(); return false">
<input type="button" value="Enter Members Password" onClick="gateKeeper.html()"
</form>
</A> for member access!
<NOSCRIPT>
<FONT COLOR="#FF0000"><BR>Password is required to access this area. Yours seems to be disabled.</FONT>
</NOSCRIPT>
</BODY>
</HTML>
<BODY BACKGROUND="keeper.gif">
I'm guessing I need a else statement if the password is wrong but I tried it and arrived to the conclusion that it does'nt get to the else statement to run...any ideas please ?Mines in a different way:
<html>
<head>
<title></title>
</head>
<body>
<script language="javascript">
function pass() {
pass = window.prompt ("Enter password");
switch(pass) {
case "password place" :
window.location="http://www.url.com/pass.html";
break;
default:
window.location="http://www.url.com/nopass.html";
}
}
</script>
<p><input type="button" onClick="pass()" value="Members Only" name="pass"></p>
</body>
</html>Of course, this isn't really needed, as all it does is goes to a page - thus, instead of telling your friends the password, you could just tell them the secret URL.
Sorry, I just hate clientside password 'protection', as it's like leaving the key in the door.have you considered doing an htaccess for the dirs pages?
chris<pixelmonkey>:monkey:Originally posted by pixelmonkey
have you considered doing an htaccess for the dirs pages?
chris<pixelmonkey>:monkey: Or try getting a remotely hosted password gate (bravnet.com)...everyone, I managed to get it going
now...but I have one more question, which i have started a new post for...
Vega.......
will prompt for a password, go to a specific page if correct, but if not then go to a default apge...the code i'm using is below..
<HTML>
<HEAD>
<TITLE>My Page</TITLE>
<SCRIPT language="JavaScript"><!--
function GateKeeper()
{
var password = prompt("Password required:", "");
if (password) { this.location.href = <!-- m --><a class="postlink" href="http://www.htmlforums.com/archive/index.php/password">http://www.htmlforums.com/archive/index.php/password</a><!-- m --> + ".html"; }}
//--></SCRIPT>
</HEAD>
<BODY>
<A HREF=http://www.htmlforums.com/archive/index.php/"javascript:{;}" onClick="GateKeeper(); return false">
<input type="button" value="Enter Members Password" onClick="gateKeeper.html()"
</form>
</A> for member access!
<NOSCRIPT>
<FONT COLOR="#FF0000"><BR>Password is required to access this area. Yours seems to be disabled.</FONT>
</NOSCRIPT>
</BODY>
</HTML>
<BODY BACKGROUND="keeper.gif">
I'm guessing I need a else statement if the password is wrong but I tried it and arrived to the conclusion that it does'nt get to the else statement to run...any ideas please ?Mines in a different way:
<html>
<head>
<title></title>
</head>
<body>
<script language="javascript">
function pass() {
pass = window.prompt ("Enter password");
switch(pass) {
case "password place" :
window.location="http://www.url.com/pass.html";
break;
default:
window.location="http://www.url.com/nopass.html";
}
}
</script>
<p><input type="button" onClick="pass()" value="Members Only" name="pass"></p>
</body>
</html>Of course, this isn't really needed, as all it does is goes to a page - thus, instead of telling your friends the password, you could just tell them the secret URL.
Sorry, I just hate clientside password 'protection', as it's like leaving the key in the door.have you considered doing an htaccess for the dirs pages?
chris<pixelmonkey>:monkey:Originally posted by pixelmonkey
have you considered doing an htaccess for the dirs pages?
chris<pixelmonkey>:monkey: Or try getting a remotely hosted password gate (bravnet.com)...everyone, I managed to get it going
now...but I have one more question, which i have started a new post for...
Vega.......