Categories:

Home / Free JavaScripts / Password Protecting / Here

Cut & Paste Password Protect a page
Credit: Not indicated

Description: The below script will provide low level password protection to a page.

Example: (Enter "letmein" as password)

Directions: Simply cut and paste the following into the <body> tags of your page. To configure the password, change letmein. To change the password protected page (the target page), change protectpage.html.

<SCRIPT>
function passWord() {
var testV = 1;
var pass1 = prompt('Please Enter Your Password',' ');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1.toLowerCase() == "letmein") {
alert('You Got it Right!');
window.open('protectpage.html');
break;
}
testV+=1;
var pass1 =
prompt('Access Denied - Password Incorrect, Please Try Again.','Password');
}
if (pass1.toLowerCase()!="password" & testV ==3)
history.go(-1);
return " ";
}
</SCRIPT>
<CENTER>
<FORM>
<input type="button" value="Enter Protected Area" onClick="passWord()">
</FORM>
</CENTER>

JavaScript Tools:
Site Info

CopyRight 1998-2014 JavaScript Kit. NO PART may be reproduced without author's permission.