This JavaScript prompts the user for a password. If it is correct, the
user can view the page, and if it is incorrect, the browser jumps to the
previous page.
This JavaScript is not completely secure, and can easily be disabled, so
don't use it to protect something that is top secret.
This code should be placed between the HEAD tags of the page:
<SCRIPT LANGUAGE="JavaScript">
<!---------- JavaScript begins...
var password = "password" ;
// The desired password
var message = "The password to view this page is 'password'";
// The message to show when the user is prompted for the password
var incmess = "Incorrect password! Access denied!";
// The message to show if the password is incorrect
var pw = prompt (message,"");
if (pw != password) {
alert (incmess);
window.history.back ();
}
// JavaScript ends ---------->
</SCRIPT>