Search
Recommended Sites
Related Links






   

Informative Articles

Content Management Systems (CMS): What They Are And Why We Love Them.
There is a buzz in the online community about a technology that empowers the average computer user with the ability to create and maintain their very own web presence. In the past, individuals who took interest in having and operating their own...

Four (4) Web Design Software You Cannot Afford Not To Have
After more than five years of hit and miss and wasting a lot of money on useless webmaster tools, I finally narrowed down my list to four (4) inexpensive but reliable and powerful webmaster tools! They are worth every penny I paid and saved me...

Meta tags and how to use them: Part 2
This tutorial continues on from Meta tag Tutorial: Part 1 and shows some of the less well known but often more interesting tags. <u><meta name="googlebot" content="nosnippet"></u> You know all those extra features like...

Triple Your Web Leads With Email Auto-Capture
Cary, NC - Converting a website to a direct marketing machine on steroids is easier than previously thought. However, it seems many companies still don't understand the awesome marketing power of the internet. Thus, they are actually losing...

Work With The Search Engines - Don't try to Outsmart the Search Engines
Contrary to the claims of high-priced SEO firms, optimizing your web site for search engines is not brain surgery. But you must first accept the fact that "spiders" - the search engine programs that read web pages - run away from non-HTML code....

 
Javascript Password Protection


The protection of web pages using a password comes up earlier or later while developing your site. The most secure way is to implement PHP, ASP or other advanced web programming languages. In this tutorial you will find out how to protect pages using Javascript, because you may need to have a very simple protection, or your current hosting may not support PHP.

The first example we are going to discuss is the prompt() function. The function calls a small box to appear, and unless you enter correct password, you will not be able to view the page. The advantage is that you can't view the source code to find out the password without turning Javascript off. The code is as follows:









Now let's look at the code. When you enter the correct password, a box appears saying that Access is Granted, and the rest of the page is loaded. If the password is incorrect, you are redirected to denied.php. I used a little trick with the password here that can stop some unexperienced hackers ;)) the FAKEPASS is not the actual password, even though you can make it look like it. This is just a variable that is described in an external file - "prompt.gif". This is another trick - the external Javascript file has an extension .gif , which is used for images. The file however contains text, and the server will correctly treat it like a text file, not an image. So the content of prompt.gif is:



var FAKEPASS = "the_real_password";



As you see, here our variable is substituted with the word "the_real_password", which is the actual password.


The second option in protecting a page with Javascript is much prettier, and it actually allows you to have several login and password accounts. The code is:



Login



style="position:absolute;top:100;left:300;visibility:hidden;">


Entrance  

 Login:  

 Password:


 



Sign up for PayPal and start accepting credit card payments instantly.