Index Previous Next

 

Protect a page
with

The GateKeeper v2.2
Example.

So far we allways used an extra page with a form to enter the password. It is however also possible to make an ordinairy hyperlink, and make a pop-up box appear to ask for the password when the visitor clicks the link. Here at the left is an example, and here again the password is "secret".


This all still works in the same way, only the way we ask for the password is different. Below is the HTML for the page that asks for the password.


<html>
<head>
<title>GateKeeper</title>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function doit() {
var password = prompt("Password required:", "")
self.location.href=password + ".htm"
}
// End -->
</SCRIPT>

</head>

<body bgcolor="#FFFFFF">
This link points to a <a href="JavaScript:doit()">secured
page</a>.
</body>
</html>
    

In red we see the function doit() that makes a pop-up box appear to ask for the password, appends ".htm" to whatever is entered there, and sends the browser to the URL it creates this way.

In blue we see the hyperlink in the text, this time not pointing to another page, but to the JavaScript function doit().

 


Top Previous Next
Last change on May 2nd 2000.