papillonstudios Posted July 29, 2010 Share Posted July 29, 2010 I was wondering how you stop a Function Execution. What i have is a basic slide show. and i want when you roll over the image it plays the slideshow but when you onMouseOut it reverts back to the first image and stops the slideshow. So far i have the slideshow working, the onMouseOver and onMouseOut fumctions working . except in the onMouseOut function i dont have it stopping the slideshow. heres my two functions and where im using them. //variable that will increment through the images var step=1 function slideit(action){ if(action == 'abort'){ return } //if browser does not support the image object, exit. if (!document.images) return document.images.slide.src=eval("image"+step+".src") if (step<6) step++ else step=1 //call function "slideit()" every 2.5 seconds setTimeout("slideit()",1000) } function slideOff() { document.images.slide.src=eval("image1.src") slideit(abort) } <img src="contact/images/wingham/01.jpg" onmouseover="slideit()" onmouseout="slideOff()" name="slide" width=150" > Link to comment https://forums.phpfreaks.com/topic/209272-stopping-a-javascript-function-execution/ Share on other sites More sharing options...
xenophobia Posted July 30, 2010 Share Posted July 30, 2010 Try to declare a variable to hold your timer object. var timer; function slideit(action) { [....] timer = setTimeout("slideit()", 1000); } function slideoff() { clearTimeout(timer): [...] } Link to comment https://forums.phpfreaks.com/topic/209272-stopping-a-javascript-function-execution/#findComment-1092928 Share on other sites More sharing options...
papillonstudios Posted July 30, 2010 Author Share Posted July 30, 2010 thanks man exactly what i wanted. Link to comment https://forums.phpfreaks.com/topic/209272-stopping-a-javascript-function-execution/#findComment-1092948 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.