Protect a page access with JAVASCRIPT onlyTag(s): HTML/CSS
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>