<script>
function yanzhengmima() {
var fuwuqi_pwd = "zixin" //密码
var mima = ""; //用户输入的密码
if(diyici) {
mima = prompt("请输入操作密码:")
}
else {
window.history.back(-1);
}
if(mima == null || mima == "") {
window.history.back(-1);
}
setCookie("mima",mima,1)
if (fuwuqi_pwd == getCookie("mima")) {
// 验证通过
$('.showPass').show()
}
else {
diyici = false
yanzhengmima()
}
}
function setCookie(cname,cvalue,exdays) {
var exdays = 1/12 //2个小时后过期
var d = new Date();
d.setTime(d.getTime()+(exdays*24*60*60*1000));
var expires = "expires="+d.toGMTString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++)
{
var c = ca[i].trim();
if (c.indexOf(name)==0) return c.substring(name.length,c.length);
}
return "";
}
let diyici = true
yanzhengmima()
</script>
标签:function,exdays,验证码,yanzhengmima,mima,访问,cname,var,页面 From: https://www.cnblogs.com/songadmin/p/16880634.html