第一种方法
<script type="text/javascript">
function password() {
var testV = 1;
var pass1 = prompt('请输入密码','');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1 == "henenseo") {//初始密码codeke
alert('密码正确');
break;
}
testV+=1;
var pass1 =
prompt('密码错误!请重新输入:');
}
if (pass1!="password" & testV ==3)
history.go(-1);
return " ";
}
document.write(password());
</script>
第二种方法
<script type="text/javascript">
function password() {
var testV = 1;
var pass1 = prompt('请输入密码:','');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1 == "henenseo") {//设置密码 初始密码codeke
alert('口令正确,进行跳转');
window.location.href="https://www.hensenseo.com/";//添加你要跳转的页面
break;
}
testV+=1;
var pass1 =
prompt('密码错误','');
}
if (pass1!="password" & testV ==3)
history.go(-1);
return " ";
}
document.write(password());
</script>