項目中需要增加一個投票功能,投票完成后自動倒計時 10 秒跳轉到首頁。
JavaScript 代碼:
// 設置超時時間為 10 秒鍾
var timeout = 10;
function show() {
var showbox = $(".showbox");
showbox.html(timeout);
timeout--;
if (timeout == 0) {
window.opener = null;
window.location.href = "index.aspx";
}
else {
setTimeout("show()", 1000);
}
}
源代碼:下載
