Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setTimeout Function 1

Status
Not open for further replies.

Stewart531

Programmer
Feb 18, 2003
36
US
Hi, I'm having a problem. It seems like I can't call a setTimeout function inside a function called by onUnload. Any ideas why this is happening?

Thanks,
Dave
 
because the document is unloading, meaning "done, finished, no longer running". if it's no longer running then how can it catch a timeout event?

of course im just guessing since i never tried it. -There are only 10 types of people in the world, those who understand binary and those who don't-

-pete
 
palbano pretty much hit the kitty on the head with that one. The browser is the big bus full of rowdy teenagers bound for what their parents call "band camp", but what they call "an entire summer of sex-ed". The setTimeout function is the one teenager saying "wait, I gotta tie my shoes."

They get left behind.

Cheers,
[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Thanks guys for the responses. What I'm trying to do in the onUnload function is to open a popup and then close it a few seconds later. Since I can't use setTimeout, is there any alternative that would work?

Thanks,
Dave
 
>> is there any alternative that would work?

does ur popup window come up? if so u can use the setTimeout in there yes?

>> pretty much hit the kitty on the head with that one

nah, i use a pitchfork... less effort required LOL -There are only 10 types of people in the world, those who understand binary and those who don't-

-pete
 
Yeah, the popup window comes up, but it is left hanging there because the setTimeout function doesn't work within the onUnload function.
 
Dave,

A cheat is to build your popup window, but not in your unload function. Just build it and stick it behind the main window. When the main window is killed, the pop-up window is still there.

Now, if you had some kind of setTimeout trigger in the popup window, then your main window's onUnload event would tweak that one variable in the popup before the main window expires. That tweak would start your timer. The end-of-timing event in the popup would be self.close(); of course.

At least, I think so.

Good luck!
[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top