abierto
abierto

Reputation: 1467

Wait popup window javascript

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?

Upvotes: 1

Views: 16281

Answers (3)

Teemu
Teemu

Reputation: 23396

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

Upvotes: 5

themightysapien
themightysapien

Reputation: 8369

just pass the function to the the settimeout

setTimeout(yourfunction,2000);

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

Upvotes: 0

Kolby
Kolby

Reputation: 2865

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.

Upvotes: 2

Related Questions