基本上我这样做:
window.onload=function wait(){
alert ("Please, wait until process has finished.");
window.location="index.jsp";
};
我需要的是一个警报窗口,或类似的东西,只有在X秒通过后才会消失/启用弹出窗口中的“确定”按钮。
我该怎么做?
答案 0 :(得分:3)
也许你需要这样的东西:
window.onload = function () {
var popup = window.open('','pop','width=200px, height=10px'),
popdoc, msg, script;
if (popup) {
popdoc = popup.document;
msg = popdoc.body.appendChild(popdoc.createElement('p'));
msg.innerHTML = 'Please, wait until process has finished.';
script = popdoc.createElement('script');
script.text = '(function () {setTimeout(function () {self.close();}, 3000);}());';
popdoc.body.appendChild(script);
}
}
的演示
答案 1 :(得分:2)
var wait = function() {
alert ("Please, wait until process has finished.");
}
setTimeout(wait, 3000);
3000是你在调用函数之前要等待的毫秒数。
答案 2 :(得分:0)
将函数传递给settimeout
setTimeout(yourfunction,2000);
这将在doc load
2秒后运行该函数