IOLS Web Site
Design Services
Learn More
About Web Design
How Do I Password
Protect A Web Page
Please send your insights and ideas via
email to webmaster@iols.net
Click
here to see a demo
Disclaimer:
The script presented and information on this page will help to protect
a page from entry
and is not intended to be a secure end all solution to password
protecting a web page
or web site. Please consult us for secure solutions to achieve
that goal.
Here's a very easy way
to password protect a web site using JavaScript.
Compliments of JavaScripts.com
(http://www.javascripts.com)
A great resource for javascripts!
Just copy and past the
code below into your web page noting the changes required shown in
the comments above each line to change
<!-- This script has been in the http://www.javascripts.com Javascript Public Library! -->
<!-- Note that though this material may have been in a public depository, -->
<!-- certain author copyright restrictions may apply. -->
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<title>Password Required</title>
<script>
//remove the line below from your page
alert("the password is enter")
//we will first ask the user if he would like to continue into this restricted area
var p=confirm("this site is pass word protected, do you still want to enter?")
if(p){
//var ans="password" input your password here between the quotes
var ans="enter"
var pass=prompt("what is the pass word")
if(pass!==ans)
{
alert("wrong you will now be transferred")
//edit the URL below
window.location="http://www.iols.com"
}else{alert("correct");}
//edit the URL below
}else{window.location="http://www.iols.com"}
</script>
</head>
<body bgcolor="#FFFFFF">
<script language="Javascript1.2">
// The following code prevents right clicking and viewing
// the source code of the page
// Script provided by The IOLS Design Team www.iols.com/design
// Set the message for the alert box
am = "This function is disabled!";
// do not edit below this line
// ===========================
bV = parseInt(navigator.appVersion)
bNS = navigator.appName=="Netscape"
bIE = navigator.appName=="Microsoft Internet Explorer"
function nrc(e) {
if (bNS && e.which > 1){
alert(am)
return false
} else if (bIE && (event.button >1)) {
alert(am)
return false;
}
}
document.onmousedown = nrc;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (bNS && bV<5) window.onmousedown = nrc;
</script>
</body>
</html>
Click here to see a demo
For more great
JavaScripts visit
JavaScripts.com
(http://www.javascripts.com)
More
Design Tips
Please send your
insights and ideas via email to webmaster@iols.net
|