Javascript passwords let you protect a site by hiding a portion of the URL. A user entering the site will have to enter the hidden part of the URL (the password) in order to enter. To set up password protection on part of your site:
Step 1: Make up a short password, such as xyz123.
Step 2: Create and upload a page called xyz123.html (this is the password-protected page).
Step 3: Add the code in the box below to the <head> section of the page where you want the visitor to enter a password.
Step 4: Use <a href="javascript:gateKeeper()"> to create a password-protected link.
Example: Click <a href="javascript:gateKeeper()">here</a> to enter my site (you need a password)
Step 5: Tell selected people the password (xyz123 in this example).
<script language="JavaScript">
<!---
function gateKeeper() {
var password = prompt("Password required:", "")
var location = password + ".html";
this.location.href = location;
}
// --->
</script>
|
Test it! The password is "mars".
This is a rip-off of Gate Keeper v2.0 by Joe Barta, which used to be available from http://junior.apk.net/~jbarta/weblinks/gate_keeper/.