The security of web pages using a password comes up before when developing your site. The most safe way is to apply PHP, ASP or other progressive web programming languages. In this tutorial you will get how to defend pages using Javascript, because you may want to have a very easy protection, or your present hosting may not support PHP. The first example we are going to treat is the prompt() function. The function calls a small box to look, and unless you enter proper password.

When you enter the accurate password, a box looks saying that Access is allowed, and the rest of the page is loaded. If the password is wrong, 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 factual password, even though you can make it look like it.

This is just a changed that is informed 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 right treat it like a text file, not an image. So the capacity of prompt.gif is As you see, here our thing is substituted with the word "the_real_password", which is the real password. The second option in defending a page with Javascript is much prettier, and it really permits .