EarthWeb
Developer.com
Site
windows 2000
visual c++
java
visual basic
javascripts
recommend it
 
Book
thinking in java
 
Interact
forum
guest book
jobs
jokes
what's new

share code
 
Resource
add resource
modify resource
new resource
 

[Internet Jobs]
-----
Java by E-mail:

Get the weekly e-mail highlights on Java!
-----

-

Protect a page access with JAVASCRIPT only


Author: Real Gagnon
Author's WebSite: http://tactika.com/realhome/realhome.html

If the password protection mechanism provided by the Web server is not available, a simple way to protect a page with JAVASCRIPT is to match the user password with the filename to be loaded.


 <HTML><HEAD>
 <SCRIPT>
 function login() {
    if (validLogin()) {
       password = document.userInfos.password.value;
       self.location.href=
         "http://www.server.com/login/"+password+".html";
       }
    }
 function validLogin() {
    if (isBlank(document.userInfos.password.value)){
       alert("Can't be blank");
       document.userInfos.password.focus();
       return false;
       }
    return true;      
    }
 function isBlank(s) {
    return (s == "");
    }
 </SCRIPT>

 <BODY onLoad="document.userInfos.password.focus();">
 <H1><CENTER>Identification </H1></CENTER>
 <CENTER><TABLE BORDER=1>
 <FORM  NAME=userInfos>
 <TR><TD>Password: </TD><TD> 
 <INPUT TYPE="password" NAME=password LENGTH=20>
 </TD></TR>
 <TR ALIGN=center>
 <TD></TD><TD>
 <INPUT TYPE="button" VALUE="Ok" onClick="login()">
 </TD></TR></TABLE></FORM></CENTER></BODY></HTML>



Posted On: 10-Jul-1999

internet.commerce



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy