Published on: Saturday 4th April 1998 By: Martin Webb
To enable this utililty to work smoothly we require one blank image blank.gif and one blank document blank.htm, and one image per protected file, for example if the password is x1y2z3 then the image x1y2z3.gif must exist, plus one enabler file per protected file, for example ex1y2z3.htm. The images should be very small, preferably 1 pixel high by 1 pixel wide, and the same color as the background color of the password entry page.
For browsers that support the document images object, we can replace the blank.gif image with the password image, e.g. x1y2z3.gif, using the testForIt() function. If the image is not loaded then the images onError event handler is invoked which is used to display an 'Incorrect password - please retype' error message using the failtIt() function.
If the x1y2z3.gif image is loaded then the images onLoad event handler is invoked
which is used to load the
The request flag is set to false or true in various places to ensure that the loading of the initial blank.gif image does not trigger the loading of another file. The returning of false in the testForIt() function ensures that the form submission is always cancelled.
For browsers that don't support the images object, but do support floating frames, i.e. Microsoft Internet Explorer 3, it creates a hidden floating frame containing the blank.htm document. We can replace the blank.htm document with the password enabler document in the testForIt() function. For example, if the password entered was x1y2z3, then the enabler document loaded will be ex1y2z3.htm. This enabler document will then load x1y2z3.htm into the main document, i.e. the parent document. If the password entered was wrong, then the enabler document will not be found and the resulting server error message hidden in the hidden floating frame.
For browsers that support neither the document images object or floating frames (e.g. Netscape Navigator 2) then the password entered is assumed to be correct and an attempt to load the file is made again using the loadIt() function.
The contents of an enabler document, e.g. ex1y2z3.htm where x1y2z3 is the password, should look like:
Note that this time the file loaded does not have the e prefix. Therefore the enabler password document is not loaded in the parent frame, but, the password protected document instead. It uses the value of the parents password form field. If it was hardcoded with the name of the password protected file instead, then each time the user pressed the back button and returned back to the password logon document, the contents of the hidden frame would always push the user back to the password protected page.
The blank.htm document should contain at least:
Try this example: Password is x1y2z3.