469,594 Members | 2,118 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,594 developers. It's quick & easy.

window.open and settimeout

Michael Winter <M.******@blueyonder.co.invalid> wrote in message news:<op**************@news-text.blueyonder.co.uk>...
On 24 Feb 2004 14:13:47 -0800, John <jo******@fastermail.com> wrote:
I would like to use setTimeout and window.open methods to pop up
window every 5 minutes. I can only manage to make the window to pop up
only twice.

function openWindow() {
window.open("popupwindow.htm", "OpenedWindow",
"width=320,height=240, scrollbars=yes,resizable=yes,status=yes");

}
function settime() {
setTimeout("openWindow()", 300 * 1000);
}

So what is the problem that is making the window never to come back
when the user closes the popped window the second time?


The solution is simple, but first, I would like to know why you would want
to do something like this. It sounds remarkably like pop-up banner
behaviour.

Of course, I don't really care personally: Opera (my browser) blocks that
kind of pop-up. However, I would be concerned for other users, and I won't
endorse something so disruptive.

Mike

This is a friendly popup window that reminds a retailer that he has
not taken care of the orders that has come to his site. He has an
option for disabling the window and also if he takes care of the
orders the window will not pop up.

John
Jul 20 '05 #1
1 7290
On 25 Feb 2004 05:33:36 -0800, John <jo******@fastermail.com> wrote:
Michael Winter <M.******@blueyonder.co.invalid> wrote in message
news:<op**************@news-text.blueyonder.co.uk>...
On 24 Feb 2004 14:13:47 -0800, John <jo******@fastermail.com> wrote:
I would like to use setTimeout and window.open methods to pop up
window every 5 minutes. I can only manage to make the window to pop up
only twice.

function openWindow() {
window.open("popupwindow.htm", "OpenedWindow",
"width=320,height=240, scrollbars=yes,resizable=yes,status=yes");

}
function settime() {
setTimeout("openWindow()", 300 * 1000);
}

[snip]
The solution is simple, but first, I would like to know why you would
want to do something like this. It sounds remarkably like pop-up
banner behaviour.

[snip]
This is a friendly popup window that reminds a retailer that he has
not taken care of the orders that has come to his site. He has an
option for disabling the window and also if he takes care of the
orders the window will not pop up.


OK. That seems reasonable.

Instead of your setTimeout() call, use setInterval():

timerID = setInterval( openWindow, 300000 );

Where timerID is a global variable. You will need to use that with
clearInterval() when you want to stop the function, openWindow, from being
called - when the retailer disables display of the window, or when there
is nothing to remind him about, for example.

The difference between setInterval and setTimeout is that setTimeout fires
only once, whereas setInterval fires continuously (once every 5 minutes,
above) until it is cancelled with clearInterval.

Good luck,
Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Les | last post: by
1 post views Thread by John | last post: by
10 posts views Thread by David McCulloch | last post: by
2 posts views Thread by Samir Pandey | last post: by
13 posts views Thread by MPH | last post: by
5 posts views Thread by Andrea A | last post: by
2 posts views Thread by John Derry | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.