Article Read. You Can Find All Kind of Articles

Home | Search Article

Search



Advanced Search

Javascript Password Protection

Kategori  Category : Web Development
Read  Times Read : 87
Date  Date : 30 July 2008 07:00

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 cant view the source code to find out the password without turning Javascript off. The code is as follows:script=prompt("Please enter the password:","")if (script == FAKEPASS){alert(Acess granted);}else {alert(Acess denied)location.href="denied.php" }// done hiding --Now lets 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:Loginfunction login(){log.style.visibility="visible"}function exit(){log.style.visibility="hidden"}style="position:absolute;top:100;left:300;visibility:hidden;"Entrance Login: Password:
 

Web Development

Most Popular Articles

Random Article 1

Random Article 2

  • LOOKs Can Be Deceiving
  • You may have heard that Looksmart Ltd have made some changes to their business model lately. In fact, Looksmart have made the profit-driven decision to move Looksmart.com from a Paid Submission based directory to a Pay Per Click based directory. The first warning shot was fired on April 3rd, with an

Random Article 3

Random Article 4

  • Keywords usage in the Meta Tags
  • Once the sites keywords have been finalized it is now time to start using them to optimize the site.The first & most obvious place to start using them is the meta tags of the site. There are three metatags that we can start to use them with. Header Description Keywords Lets look at them one by one:
  • eCommerce Web Design Solutions
  • eCommerce web design is a lot more than just putting your company brochure on the net or adding an internet shopping cart to your existing product catalog. There are some fundamental differences between doing business online and doing business the traditional way. Before you design your business web
indir notebook hiperucuz.com teknoloji forum hava kargo adtech ile reklam 2.0 dönemi ba?l?yor ve Trkycmhrytllbtpydrklcktr r10.net seo yar??mas?