JavaScript - Cancelling All Timeouts In One
Is there a simple way to cancel all active timeouts without the need to reference each one individually ?
Similar TutorialsI know this is a common question. I have read the posts, including http://www.javascriptkit.com/javatut...plejava3.shtml which illustrates this very problem. Wherein lies the heart of this issue is in my complete lack of knowledge of how Javascript works, and the literal examples in that explanation don't seem to be present in the scripts in question. The subject page I'm trying to figure out is www.barkingtuna.com/indexMAG.html. One set of Scripts creates a full width sliding banner at the top, and the other script serves to create a "magnifying glass" effect for the remaining images on the page. With them both on the page, only the magnifying glass rollover effect works. If I remove the "mag.js" script, the sliding banner functions again, but I lose the magnifying glass. I was able to locate "onload" in various forms within attached the ddpowerzoomer.js, mag.js, js\jquery.core.js. All that said, I am much better at basic HTML, Design, and SEO, and leave this up to the experts. I hope that is concise enough and that someone can point me in the right direction. Much Appreciation, TexAz I don't know how to work with timeouts. I have a simple blinking image. but I'm not sure how to set multiple timeouts? Basically I want the image to blink to another one for 400, then return to the first image for 5000 here's the basic starting point I have: Code: <script type="text/javascript"> var img_off = new Image(); img_off.src = 'images/blink.png'; var img_on = new Image(); img_on.src = 'images/orho2.png'; function blink() { var e = document.getElementById("blinking_orho"); e.src = (e.src == img_on.src) ? img_off.src : img_on.src; setTimeout("blink();", 5000,); } </script> I'm running into issues while trying to make some simple code to loop through and display different combinations of 3 colours. I want to show 3 boxes on screen and then loop through/increment each possible combination of colours. For simplicity's sake I'm trying to go from black to white in each box like this: (box1rgb/box2rgb/box3rgb) step 1: 000 000 000 step 2: 000 000 111 step 3: 000 000 222 . . . step 256: 000 000 255255255 step 257: 000 111 000 step 258: 000 111 111 step 259: 000 111 222 . . . step 512: 000 111 255255255 step 513: 000 222 000 step 514: 000 222 111 . etc. Yes, I know the thing will take a long time to complete! The colour is being set by the statement document.getElementById("box#").style.backgroundColor = "rgb(" + p1 + "," + p1 + "," + p1 + ")"; where p1 is the incrementing variable. Firstly I tried to do it using nested "for" loops. Code: for (p3=0;p3<=255;p3++) { document.getElementById("box03").style.backgroundColor = "rgb(" + p3 + "," + p3 + "," + p3 + ")"; for (p2=0;p2<=255;p2++) { document.getElementById("box02").style.backgroundColor = "rgb(" + p2 + "," + p2 + "," + p2 + ")"; for (p1=0;p1<=255;p1++) { document.getElementById("box01").style.backgroundColor = "rgb(" + p1 + "," + p1 + "," + p1 + ")"; } } } But of course the code executes far too rapidly for each combination to be seen. It all chewed up lots of CPU and nothing was smooth. To slow the process, I tried a single recursive loop using a timeout statement: Code: function loopandshow() { document.getElementById("box01").style.backgroundColor = "rgb(" + currentcolour + "," + currentcolour + "," + currentcolour + ")"; currentcolour += 1; if (currentcolour <= 255) window.setTimeout("loopandshow();", 20); } This worked smoothly for a single box but I couldn't work out how to nest this format 3 levels deep and have each level increment only when the deeper level had completed the cycle. Any advice would be gratefully appreciated. Thanks in advance. ok so all I want to do is allow a user to confirm that they've clicked the deactivate button...if they click 'ok' deactivate the affiliate...else just return to the list what is happening is I click on deactivate and the confirmation pops up (so far so good); if I click ok then it deactivates the affiliate the way it's supposed to - but if I click cancel it still deactivates the affiliate instead of returning to the list Code: <script type="text/javascript"> function confirmation() { if (confirm("Are you sure you want to deactivate this affiliate? Doing so will deactivate all of its users as well.")){ window.location = "affiliates.php?deactivate='.$_GET['deactivate'].'"; } else { window.location = "affiliates.php"; } } </script> any help is greatly appreciated! |