I have this code: It’s very simple. I create an interval, and that works fine, but when I clear it, that statement is the only thing that fails.
clearinterval(interval);
This line fails, dragging don the whole function with it. If I comment out this one line, discomodeoff() works perfectly, besides that my interval is still running.
var interval;
function discomodeon() {
interval = setInterval( 'flashtext()', 50 );
document.body.style.background = "#000000";
discoball.style.visibility="visible";
on.style.display="none";
off.style.display="block";
music.innerHTML = "<embed src='discomusic.mp3' autostart='true' loop='true' hidden='true'></embed>";
}
function discomodeoff() {
clearinterval(interval);
document.body.style.background = "#FFFFFF";
discoball.style.visibility="hidden";
on.style.display="block";
off.style.display="none";
music.innerHTML = "";
}
I’m not sure why it fails, but it causes discomodeoff() to fail.
It’s
clearInterval, notclearinterval.