setInterval clearInterval
inSide-j00ls
- javascript
0 Struppi
I have the following function that starts downward scrolling:
function NachUnten (mausaufbild) {
var aktiv = window.setInterval("window.scrollBy(0, +10)", 50);}
this works nicely - but calling a second function with clearInterval(aktiv); does not work - only calling clear at the same time cancels the scrolling process but then I cant scroll at all - even if I call the same function with a variable that decides whether or not to call clearInterval it never works. How can I reference the interval once I have started it ?
Help much appreciated!
function NachUnten (mausaufbild) {
var aktiv = window.setInterval("window.scrollBy(0, +10)", 50);}this works nicely - but calling a second function with clearInterval(aktiv); does not work - only calling clear at the same time cancels the scrolling process but then I cant scroll at all - even if I call the same function with a variable that decides whether or not to call clearInterval it never works. How can I reference the interval once I have started it ?
you must declare "aktiv" global. Just remove var
Struppi.