需要修改這串腳本,目前頁面是login.html,輸錯三次密碼後會跳轉到nologin.html頁面,現在新增一個頁面:wait.html。想達到的效果是一旦進入nologin.html,5分鐘內進入login.html會自動跳轉到wait.html,5分鐘後進入login.html可以正常進入。cookie實現
var errCount = 0;
function check() {
if (errCount < 3) {
var name = document.getElementById("name").value;
var pass = document.getElementById("pass").value;
if (name == "賬號" && pass == "密碼") {
errCount = 0;
alert("登入成功");
window.document.f.action = "in.html";
window.document.f.submit();
} else {
errCount++;
alert("用戶名或密碼連續錯誤次數" + errCount);
}
}
if (errCount == 3) {// 連續輸入3次賬號密碼錯誤
location.href = "nologin.html";
}
}
更正下,setCookie放錯位置
function setCookie() {
var d = new Date();
d.setMinutes(d.getMinutes() + 5);
document.cookie = 'visit1=1;expires=' + d.toGMTString();
}
if (document.cookie.indexOf('visit1=1') != -1) location = 'wait.html';/////////////////////
var errCount = 0;
function check() {
if (errCount < 3) {
var name = document.getElementById("name").value;
var pass = document.getElementById("pass").value;
if (name == "賬號" && pass == "密碼") {
errCount = 0;
alert("登入成功");
window.document.f.action = "in.html";
window.document.f.submit();
} else {
errCount++;
alert("用戶名或密碼連續錯誤次數" + errCount);
}
}
if (errCount == 3) {// 連續輸入3次賬號密碼錯誤
setCookie();//////////////////////
location.href = "nologin.html";
}
}