admin管理员组

文章数量:1290957

Basically I'm doing this:

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

What I need is, an alert window, or something similar that will disappear/enable the "OK" button in the popup window, only after X seconds are passed.

How can I do this?

Basically I'm doing this:

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

What I need is, an alert window, or something similar that will disappear/enable the "OK" button in the popup window, only after X seconds are passed.

How can I do this?

Share Improve this question asked Feb 7, 2013 at 9:06 abiertoabierto 1,4677 gold badges29 silver badges61 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

Maybe you need something like this:

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

A demo at jsFiddle

var wait = function() {
    alert ("Please, wait until process has finished.");
}
setTimeout(wait, 3000);

The 3000 is the miliseconds you want to wait before it calls the function.

just pass the function to the the settimeout

setTimeout(yourfunction,2000);

this will run the function after 2 sec of the doc load

本文标签: Wait popup window javascriptStack Overflow