Unless you know the password, you can't access the document. Actually
the password is the name of the document. If you make your password red_rose,
then just name the target document red_rose.html. Easy! Once more because
I have gotten a surprising number of letters asking how to change the
password... The password is the name of the document. If you make your
password red_rose, then just name the target document red_rose.html By
the way, the password for the previous example is redrum. Now that you
see what it does, I'll show you how to easily add it to your pages. But,
before I do, let me make something absolutely clear... this is a very
low level security device. If you are a NSA employee, do not use this
for hiding national secrets. If you are the President of MasterCard, do
not put everyone's credit card numbers behind this thing. However, if
you're a regular guy that has a page or two that you don't want every
Tom, Dick and BlowHard visiting, then this should safely do the trick.
You can easily change the default status bar message when the mouse is
over the link. Open index.html and alter the following line... [snip]...
// You can edit the following line to change the status bar message. var
statusMsg = "Password Protected Area" ...[snip]
--------------------------------------------------------------------------------
Let's suppose that for whatever reason, you wanted to have the target
doc in another directory (such as targets/). In other words, instead of
looking for redrum.html you want it to look for targets/redrum.html (but
you don't want your visitor to have to type in targets/). Just edit the
following line in the script from this... this.location.href = password
+ ".html"; To this... this.location.href = "targets/" + password + ".html";
TRY IT (password is redrum) Also notice in this example there is a blank
html doc named index.html in the targets directory.
--------------------------------------------------------------------------------
When the Gate Keeper prompt box appears, it says Password required:.
You can change this by editing the following line in the script... var
password = prompt("Password required:", ""); TRY IT (password is redrum)
--------------------------------------------------------------------------------
You can make Gate Keeper work within frames like so. (password is redrum)
Just edit the following line in the script from this... this.location.href
= password + ".html"; To this... parent.rightframe.location.href = password
+ ".html"; Here is a zip file containing the documents for the above example.
Where rightframe is the NAME of the target frame. The scripting goes on
the page with the link. If you need to brush up on frames, wander on over
to Frames Tutor for a refresher.
--------------------------------------------------------------------------------
You can specify default text in the prompt box if you wish.. Here is
an example. (password is redrum) Just edit the following line in the script
from this... var password = prompt("Password required:", ""); To this...
var password = prompt("Password required:", "Enter your secret code here");
--------------------------------------------------------------------------------
You could string together 2 prompt boxes for a mock username & password
verification. Here is an example. (username is slip, password is mahoney)
Here is the altered code for the above example... [snip]... function gateKeeper()
{ var username = prompt("Enter your username:", ""); var password = prompt("Enter
your password:", ""); this.location.href = username + "/" + password +
".html"; } ...[snip] Now, I can hear a question bubbling up. The answer
is.. no, you can't get them to appear on the same prompt box. It has to
be one, then another. And that's it for version 2 of the GateKeeper. Have
fun with it!
|