JavaScript Instance Tutorial (7) using JavaScript for password protection

Source: Internet
Author: User
Tags password protection
javascript| Tutorial

Use JavaScript for password protection

With the rapid development of the Internet, the earth has become smaller, people can cross the boundaries of time and space to communicate in cooperation. But then there are some vandalism hackers, which makes it possible for program designers to think about hacking in their applications, so it's natural to think of protection. This tutorial will teach you how to use JavaScript for password protection. There are several ways to use JavaScript to password protect a Web page. One of the earliest methods is to be tolerant of the user without knowing the target filename, as follows:

<script language= "JavaScript" ><!--

function Go () {

Window.location.href = "http://www.somewhere.com/" +

Document.formName.passwordName.value + '. html ';

return false;

}

file://--></ Script>

The way to use this JavaScript script in a Web page is:

<form name= "FormName" >

Enter Password: <input type= "Password" name= "Passwordname"

Value= "" size=8>

</FORM>

One disadvantage of using this JavaScript script is that users can check the source code and discover the location of the file directory. To find better security, you should protect your file directory by placing a default file (index.html) into JavaScript scripts so that your server always sends a message when the directory is requested. If you do not include a default file in your file directory, the Web server sends all the files contained in your directory, which is the hidden danger of insecurity.

The point here is that using JavaScript to password-protect a file is not a very safe way to do this. To achieve a higher safety factor, CGI or server functions are recommended here, such as. htaccess.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.