Use prompt for password checking
<html>
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>My First JavaScript Script</title>
<script language="JavaScript">
<!--
function passCheck(){
if(prompt("Please enter your password","") == "letmein"){
window.location = "http://www.java2s.com";
}else{
window.location = "http://www.java2s.com";
}
}
//-->
</script>
</head>
<body onload="passCheck()">
<noscript>
Your browser either does not support JavaScript or your have it turned off.
</noscript>
</body>
</html>
Related examples in the same category