|
Answer by: Kristen Jourdonais, Aplus.Net
Knowledge Base Support
One way to password protect a single webpage
on your site is by using JavaScript. This will only permit access
to users that you want viewing your page. This is a simple solution
for protection of a single page. Here is how to set up a password
protected page on your webspace:
- Open
a basic text editing program, like Notepad, WordPad, etc. Begin
by typing the opening tags: <html><head>
- Type
the title of your page and close the title with a tag. For example: <title>Protected
Page: Please enter password</title>
- Type
the following: <script language="Javascript"> (This
command tells the browser a script is about to begin.)
- Press
the Enter key and type the following: //prompt. Press the Enter key
again.
- Enter
the prompt by typing the following: var password = prompt("Enter
in the password"""); (There are three double-quotation
marks after the word "password" and a semicolon after
the last parentheses.)
- Type
the following, replacing "pass" with the word or numbers
the password will be: if (password == "pass")
- Now
type the following, replacing "correct.html" with the
name of the page the correct user is directed to: {location
= "correct.html"} (This tells the browser to send
the user who enters the correct password to this page.)
- Send
users who type the incorrect password to an error page by typing
the following, replacing "error.html" with the error
page you have created: else {location = "error.html"}
- End
the script by typing the following: //--></script>
- Close
the scripted section of the page by typing the follow: </head>
- Add
a body section for browsers that do not read JavaScript: <body>This page
is designed for viewing by Netscape 2.0, Internet Explorer 3.0
or above. Please upgrade your browser and return soon!</body>
- Close
the Web page by typing: </html>
- Save
the page (for example, save it as "password.html").
When a visitor enters the correct password,
they are taken to the protected page. If they are not, they will
be taken to the page that you have designated as your error page
(called "error.html" in this document).
|