1

基本上我正在这样做:

 window.onload=function wait(){
     alert ("Please, wait until process has finished.");
     window.location="index.jsp";
 };

我需要的是一个警报窗口或类似的东西,只有在 X 秒过后才会消失/启用弹出窗口中的“确定”按钮。

我怎样才能做到这一点?

4

3 回答 3

5

也许你需要这样的东西:

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);
    }
}

jsFiddle的演示

于 2013-02-07T10:06:59.673 回答
2
var wait = function() {
    alert ("Please, wait until process has finished.");
}
setTimeout(wait, 3000);

3000 是在调用函数之前要等待的毫秒数。

于 2013-02-07T09:09:05.530 回答
0

只需将函数传递给 settimeout

setTimeout(yourfunction,2000);

这将在文档加载 2 秒后运行该函数

于 2013-02-07T09:09:54.917 回答