给博客添加密码访问进入

如果需要给博客或者html页面加一个简单的密码,需要密码才能访问。
其实加一段JS就可以,这段JS代码加在body和/body中间位置即可。

方法一

<script type="text/javascript">   
function password() {   
var testV = 1;   
var pass1 = prompt('请输入密码','');   
while (testV < 3) {   
if (!pass1)   
history.go(-1);   
if (pass1 == "codeke") {//初始密码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">   
loopy()   
function loopy() {   
var sWord =""  
while (sWord != "codeke") {//设置密码 初始密码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 == "codeke") {//设置密码 初始密码codeke
alert('口令正确,进行跳转');   
window.location.href="http://www.codeke.cn/";//添加你要跳转的页面
break;   
}    
testV+=1;   
var pass1 =    
prompt('密码错误','');   
}   
if (pass1!="password" & testV ==3)    
history.go(-1);   
return " ";   
}    
document.write(password());   
</script>

 

教程分享

win11恢复传统右键菜单

2023-4-24 15:28:50

教程分享

CorePress主题美化之小工具 mac 样式

2023-5-3 15:55:09

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索