Javascript实现密码访问


<script type="text/javascript">
function password() {
var testV = 1;
var pass1 = prompt('请输入密码','');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1 == "123") {//初始密码123
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('Sorry,该页只限熟人浏览,请输入密码:','');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1 == "123") {//初始密码123
alert('一看你就是自己人,口令正确!');
window.location.href="https://www.qiangwl.com";//修改需要密码认证的网页
break;
}
testV+=1;
var pass1 =
prompt('朋友,密码不对!:(','');
}
if (pass1!="password" & testV ==3)
history.go(-1);
return " ";
}
document.write(password());
</script>

代码三

<script type="text/javascript">
loopy()
function loopy() {
var sWord =""
while (sWord != "123") {//初始密码123
sWord = prompt("输入正确密码才能登陆!")
}
alert("AH…欢迎光临!")
}
</script>

 


把上述代码加到网页头部模版 /head 标签前即可.

声明:Net-X|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - Javascript实现密码访问


Carpe Diem and Do what I like