|
-
Apr 17th, 2005, 04:03 AM
#1
Thread Starter
Addicted Member
JavaScript:Passwords
I know that javascript isn't a reliable source for passwords, but can anyone give me a quick examlpe on how to to a password protected page?
P.s. most of my users will be stupid people who hardly know how to use IE properly, let alone know what the source means!
-
Apr 18th, 2005, 03:57 PM
#2
Fanatic Member
Re: JavaScript:Passwords
Can't help you much with javascript to password protect a webpage but..
Have you considered using htaccess to password protect directories? Very secure, username/passwords are only stored server side and the server/browser will handle the negotiations for you, and simple to implemente.
-
Apr 18th, 2005, 04:08 PM
#3
Re: JavaScript:Passwords
Have a look at the attatched file.
That is a very secure example (Well, about as secure as you can get using Javascript).
Note: I did not write this but, thought you may find it useful 
Cheers,
RyanJ
-
Apr 19th, 2005, 11:17 AM
#4
Thread Starter
Addicted Member
Re: JavaScript:Passwords
any siimpler ones? something like:
"if password="easy" then goto www.blahblahblah.com"
it's not like i'm protecting nuclear silos, or personal documents, just a friends section sort of thing.
I know no-one in my school who knows about viewing the page source!
-
Apr 19th, 2005, 06:46 PM
#5
Member
Re: JavaScript:Passwords
Try this out:
PHP Code:
<html>
<head>
<script type="text/javascript">
function passwordProtect()
{
var pass = "somepassword";
var protect = prompt("Enter the password","");
if(protect != pass)
{
location.href="http://www.google.com";
}
else
{
location.href="http://www.vbforums.com";
}
}
onload=function(){passwordProtect();}
</script>
</head>
<body>
</body>
</html>
-
Apr 20th, 2005, 01:52 AM
#6
Fanatic Member
Re: JavaScript:Passwords
 Originally Posted by Brandoe85
Try this out:
PHP Code:
<html>
<head>
<script type="text/javascript">
function passwordProtect()
{
var pass = "somepassword";
var protect = prompt("Enter the password","");
if(protect != pass)
{
location.href="http://www.google.com";
}
else
{
location.href="http://www.vbforums.com";
}
}
onload=function(){passwordProtect();}
</script>
</head>
<body>
</body>
</html>
Now I am going to be a little critical here. That code there seems kind of redundant in that you created a closure to call a function.
Don't take it the wrong way, lol, it just struck me funny when I saw that.
ajames, another option might be (if it is available to you), create an ASP page that contains you passwords that you need to authenticate with, then create an HTML form that POSTS the username and password to the ASP page. Doing it this way would keep people from trying to break in.
Just thought I would mention it.
-
Apr 20th, 2005, 01:38 PM
#7
Thread Starter
Addicted Member
Re: JavaScript:Passwords
tried asp, but is way to complicated as i have no server (yet), however, the code that was supplied wouldn't let me enter anything in! can someone try and change this?
thanks in advance.
-
Apr 22nd, 2005, 12:47 PM
#8
Member
Re: JavaScript:Passwords
Hmmm, it's working for me in IE6 and FF1.0.1. Did the prompt pop up at all? Or what happend exactly? Maybe javascript is disabled?
Good luck;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|