|
Password Protect >>>
This JavaScript is just like the previous Multiple Users one, but doesn't use a table interface to login. Instead, after clicking the Login! button, the script will ask them for their username and password, and then perform the password-protection.
Add the below code to the <body> section of your page:
<script
language="javascript"
type="text/javascript">
function
LogIn(){
loggedin=false;
username="";
password="";
username=prompt("Username:","");
username=username.toLowerCase();
password=prompt("Password:","");
password=password.toLowerCase();
if
(username=="guest"
&&
password=="login")
{
loggedin=true;
window.location="home-page.html";
}
if
(username=="guest2"
&&
password=="login2")
{
loggedin=true;
window.location="home-page2.html";
}
if
(loggedin==false)
{
alert("Invalid
login!");
}
}
</script>
<center>
<form><input
type=button
value="Login!"
onClick="LogIn()"></form>
</center>
|
|