Javascript Password Safeguard


The protection of lacework pages using a password comes up earlier or subsequent while developing your site. The most secure hang-up is to apparatus PHP, ASP or other contemporary netting programming languages. In this tutorial you testament asset elsewhere how to protect pages using Javascript, now you may demand to retain a bare elementary protection, or your ongoing hosting may not facilitate PHP.
The headmost paradigm we are going to debate is the prompt() function. The service calls a little box to appear, and unless you enter exactly password, you will not be able to opening the page. The utility is that you can't outline the source rule to bargain outside the password without turning Javascript off. The statute is as follows:


Now let's gun at the code. When you enter the fair password, a box appears saying that Access is Granted, and the rest of the stage is loaded. Provided the password is incorrect, you are redirected to denied.php. I used a petite trick with the password here that can cease some unexperienced hackers ;)) the FAKEPASS is not the actual password, much though you can cook up it attending commensurate it. This is aloof a variable that is described in an outermost record - "prompt.gif". This is another trick - the out Javascript folder has an interval .gif , which is used for images. The case nevertheless contains text, and the server will exactly treat it close a content file, not an image. So the content of prompt.gif is:

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

The moment possibility in protecting a sheet with Javascript is all the more prettier, and it truly allows you to compass indefinite login and password accounts. The code is: