[thelist] rotating images
Keith
cache at dowebs.com
Mon Nov 19 18:05:07 CST 2001
> is it possible to stop this rotating cycle with an onClick action?
> thisAd = 0
> imgCt = adImages.length
> function rotate() {
> if (document.images) {
> thisAd++
> if (thisAd == imgCt) {
> thisAd = 0
> }
> document.frm.src=adImages[thisAd]
> setTimeout("rotate()", 1 * 200)
> }
> }
==================================
Yeah....
First add another global variable
rotate_on=1 <!--add this var-->
Then create a stop function and aim your stopper onClick event at it:
function stop(){rotate_on=0} <!--like so-->
Then break your loop apart from the originating call so the
originating call simply sets a global variable and starts the loop
(and can restart the loop if needed)
function rotate() {
rotate_on=1
rotator()
}
function rotator(){
if (document.images) {
thisAd++
if (thisAd == imgCt) {
thisAd = 0
}
if(rotate_on==1){ <!--add this line-->
> document.frm.src=adImages[thisAd]
> setTimeout("rotator()", 1 * 200)
} <!--add this curly brace-->
> }
> }
There are more elegant ways but this crude interrupt will work
keith
More information about the thelist
mailing list