...

View Full Version : Simple Pimple Password



W-Unit
11-10-2004, 12:16 AM
Alright, I'm a JavaScript noob, and I was hoping someone could help me with this password script. Hard as I've tried, I can't find a JavaScript password protection program other than login gates which provide next to no protection since a user can type the destination page in his URL bar (e.g. if you require a password to get into happy.html they can simply skip the password gate and type /happy.html in the end of their URL bar). I want one that triggers on an onLoad event. I know this involves revealing the password in the source code, but I'm ok with that since I have a source code encrypter that translates source code to ASCII character numbers (%32 = space etc) and anti-right click script, and the people I'm dealing with aren't exactly the most computer-savvy group you ever saw (but they WILL figure it out if I don't use an onLoad).
Here's what I've come up with. Nothing happens when the page loads, and Mozilla doesn't show any errors in the JavaScript Console:

<SCRIPT LANGUAGE="JavaScript">
function pass() {
var password = prompt('What is the password?');
var correctpass = 'ak47';
if ( password != correctpass ) {
alert 'Wrong!';
window.location = 'http://www.yahoo.com';
}
else {
alert 'Right';
}
}</SCRIPT>
Of course the script is triggered with a normal <BODY onLoad="pass()">


What's wrong and does anybody know of a script that does this?

Brandoe85
11-10-2004, 01:14 AM
Your alerts are missing the '(' and ')'


<SCRIPT LANGUAGE="JavaScript">
function pass() {
var password = prompt('What is the password?');
var correctpass = 'ak47';
if ( password != correctpass ) {
alert('Wrong!');
window.location = 'http://www.yahoo.com';
}
else {
alert('Right');
}
}</SCRIPT>

hemebond
11-10-2004, 04:01 AM
And what if they have Javascript disabled or look at your source code?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum