free hosting   image hosting   hosting reseller   online album   e-shop   famous people 
Free Website Templates
Free Installer

Password Prompt


This script prompts the user for a password.

If the password is correct, the desired page will load in a new window.


Paste all of the code below into the head section of your page:

How It Works


This uses much of the prompt code from Using Prompt Boxes.

In this script, the password is the name of the desired HTML page to be loaded.

The password is assigned to the variable pword.

A second variable, newpage , adds the .html extension to the password.

If a null value is entered, an error alert pops up, and the page is refreshed for another try.

Otherwise, a new full screen page opens, whose URL is somepassword.html.

If the password is incorrect, the new window will contain a Page Cannot Be Displayed message.


The advantage of this script is that the user can view the source code and still be unable to work out the password.

The disadvantage is that the user may stumble on another genuine page inside your folder.

For example, if the user types in mypage , you may well have a page called mypage.html on your site.

For best results:
  • give your new page an unusual name that is difficult to guess - eg. skippitybippity.html
  • place it in a folder with no other HTML files
  • if possible, place you protected files on a different server

  • Not a foolproof script by any means, but useful for basic protection.


    Try It Out

    The password is testpage:
    Open Password Test page





    © 2001 CyberSchool