欢迎光临
我们一直在努力

如何给网页HTML添加简单的密码才可访问网站页面,三种简单的JS方法

如何给网页HTML添加密码访问网站页面三种简单的JS方法。把以下三种方法任意选择一种JS代码加在body和/body中间位置即可实现。快来试一下吧!!!

方法一:

<script type="text/javascript">   
loopy()   
function loopy() {   
var sWord =""  
while (sWord != "henenseo") {//设置密码 初始密码codeke
sWord = prompt("输入正确密码才能登陆!")   
}   
alert("欢迎访问")   
}   
</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('密码正确');   
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>

 

赞(0) 打赏
未经允许不得转载:新起点博客 » 如何给网页HTML添加简单的密码才可访问网站页面,三种简单的JS方法

评论 抢沙发

评论前必须登录!