页面使用密码保护代码

这是一个由JS实现的网页密码保护代码,在进入网页前需要在弹出框中输入密码才可以,不过现在不怎么用了,一般情况下,目前都在后台处理这种功能,用户输入用户名和密码后交给服务器处理,然后再返回信息,若登录无误就可看到某些内容

代码如下所示:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>密码保护相应页面</title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
function password() {
var testV = 1;
var pass1 = prompt('请输入密码(密码是shenlong):','');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1 == "shenlong") {
alert('密码正确!');
break;
}
testV+=1;
var pass1 =
prompt('密码错误!请重新输入:');
}
if (pass1!="password" & testV ==3)
history.go(-1);
return " ";
}
document.write(password());
</SCRIPT>
</body>
</html>

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdgsgy.html