...

View Full Version : Using clearInterval in body tag?



taypandt
09-29-2012, 05:05 AM
Right now I have two functions that cycle through text and images using the setInterval method, called using onload in the body tag:


<body onload="var changeImg=setInterval ('cycleTools()',4000);
var changeTxt=setInterval ('cycleTxt()',16000);">

Is there some way to use clearInterval with onunload without creating a specific function for it? A way similar to how I created setInterval with onload?

Thanks!

Philip M
09-29-2012, 08:23 AM
window onunload = "clearInterval('cycleText()')";

But what is the point? If the page is unloaded then the setInterval function is automatically terminated.

The Moving Finger writes; and, having writ,
Moves on: nor all your piety nor wit
Shall lure it back to cancel half a line,
Nor all your tears wash out a word of it.

-- Omar Khayyam

taypandt
09-29-2012, 01:09 PM
It's fine without in Chrome, but for some reason refreshing the page in Firefox doesn't reset the cycled text. The images reset and start from the beginning, but not the text that's cycling next to it, so they no longer match.

Philip M
09-29-2012, 07:08 PM
It's fine without in Chrome, but for some reason refreshing the page in Firefox doesn't reset the cycled text. The images reset and start from the beginning, but not the text that's cycling next to it, so they no longer match.

That sounds like some problem with the script that causes the text cycling.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum