GearPop Blog

How to password protect your HTML web page

So, let’s say you want to password-protect a webpage. An example of this is the patrons-access page on David Di Franco’s site .

Screen Shot 2014-07-03 at 17.07.14

Here we’ll present you the easiest method on how to do this (without special graphics):

1. Start your .html document with <html> <head> tags

2. Find a title for it with the <title> tag ex. Authenticate

Screen Shot 2014-07-03 at 17.10.00

 

3. Use this script:

” <script language=”Javascript”>

var password=prompt(“YourPasswordHere”);

{ location=”nameofthepageforthecorrectpassword.html”}

else { location=”nameofthepageforawrongpassword.html”}

</script>”

4. Enter the tag </head> to finish the head

5. Insert <body> tag for the browsers that don’t support Javascript

6. Write some text like “update your browser” or something else.

7. Close the tag </body>

8. Close the tag </html>

Your final code should look like this:

“<html>

<head>

<title> Authenticate </title>

<script language=”Javascript”>

var password=prompt(“YourPasswordHere”);

{ location=”nameofthepageforthecorrectpassword.html”}

else { location=”nameofthepageforawrongpassword.html”}

</script>

<body>

Your browser is unsupported, update it if you want to get this page working

</body>

</html>

 

PLEASE DON’T FORGET TO SAVE YOUR FILE WITH THE EXTENSION “.html”(Sorry for the caps =] )

 

 

About the Author Tudor Coman

My Name is Tudor. I am a teenager in Bucharest, Romania. I enjoy Computer Science. I consider myself an amateur because I still have a lot to learn in this direction.

My main interests are coding and concepting. I think I am better at concepting, since I still have to learn a lot of coding. I have other hobbies like badminton, basketball and photography for recreation or holiday.

My Name is Tudor. I am a teenager in Bucharest, Romania. I enjoy Computer Science. I consider myself an amateur because I still have a lot to learn in this direction.

My main interests are coding and concepting. I think I am better at concepting, since I still have to learn a lot of coding. I have other hobbies like badminton, basketball and photography for recreation or holiday.

Leave a Reply

Your email address will not be published. Required fields are marked *