clearInterval Not working on IE
-
Here is the code....it works fine on mozilla but on IE clearInterval doesn't work,,...
.imgf{width:300px; height:250px;} #img2{z-index:1000;} window.onload=inItAll; var j=0; var N=2; function inItAll() { document.getElementById("img1").onclick=click; } function click() { if(navigator.appName=="Netscape") { j=0.9; setInterval("fadeN()",40); } else { j=90; var fI = setInterval("fadeI()",40); } } function fadeN() { j=j-0.1 if(j>0.4) { document.getElementById("img1").style.opacity= j; } else { j=0.4; window.clearInterval(); document.getElementById("img1").src = "images/"+2+".jpg"; setInterval("showN()",40); } } function showN() { if(j<1) { document.getElementById("img1").style.opacity= j; j=0.1 + j; } else { window.clearInterval(); document.getElementById("img1").style.opacity= 1; } } function fadeI() { j=j-10 if(j>40) { document.getElementById("img1").style.filter ="alpha(opacity="+j+")"; } else { j=40; window.clearInterval(fI); document.getElementById("img1").src = "images/2.jpg"; var sI = setInterval("showI()",40); } } function showI() { if(j<100) { document.getElementById("img1").style.filter ="alpha(opacity="+j+")"; j=10 + j; } else { document.getElementById("img1").style.filter ="alpha(opacity="+100+")"; window.clearInterval(sI); } } 
it gives unwanted flicks on IE coz clearInterval did not work..... -
Here is the code....it works fine on mozilla but on IE clearInterval doesn't work,,...
.imgf{width:300px; height:250px;} #img2{z-index:1000;} window.onload=inItAll; var j=0; var N=2; function inItAll() { document.getElementById("img1").onclick=click; } function click() { if(navigator.appName=="Netscape") { j=0.9; setInterval("fadeN()",40); } else { j=90; var fI = setInterval("fadeI()",40); } } function fadeN() { j=j-0.1 if(j>0.4) { document.getElementById("img1").style.opacity= j; } else { j=0.4; window.clearInterval(); document.getElementById("img1").src = "images/"+2+".jpg"; setInterval("showN()",40); } } function showN() { if(j<1) { document.getElementById("img1").style.opacity= j; j=0.1 + j; } else { window.clearInterval(); document.getElementById("img1").style.opacity= 1; } } function fadeI() { j=j-10 if(j>40) { document.getElementById("img1").style.filter ="alpha(opacity="+j+")"; } else { j=40; window.clearInterval(fI); document.getElementById("img1").src = "images/2.jpg"; var sI = setInterval("showI()",40); } } function showI() { if(j<100) { document.getElementById("img1").style.filter ="alpha(opacity="+j+")"; j=10 + j; } else { document.getElementById("img1").style.filter ="alpha(opacity="+100+")"; window.clearInterval(sI); } } 
it gives unwanted flicks on IE coz clearInterval did not work..... -
I don't know anything about jquery......it's will take long to understand and implement that coz it's new technology for me...so plz can u help me with this in Javascript code.... Thnx...
-
I don't know anything about jquery......it's will take long to understand and implement that coz it's new technology for me...so plz can u help me with this in Javascript code.... Thnx...
-
I don't know anything about jquery......it's will take long to understand and implement that coz it's new technology for me...so plz can u help me with this in Javascript code.... Thnx...
$("#img1).fadeIn();
This is too difficult for you? :rolleyes:
I know the language. I've read a book. - _Madmatt
-
-
I don't know anything about jquery......it's will take long to understand and implement that coz it's new technology for me...so plz can u help me with this in Javascript code.... Thnx...
-
Here is the code....it works fine on mozilla but on IE clearInterval doesn't work,,...
.imgf{width:300px; height:250px;} #img2{z-index:1000;} window.onload=inItAll; var j=0; var N=2; function inItAll() { document.getElementById("img1").onclick=click; } function click() { if(navigator.appName=="Netscape") { j=0.9; setInterval("fadeN()",40); } else { j=90; var fI = setInterval("fadeI()",40); } } function fadeN() { j=j-0.1 if(j>0.4) { document.getElementById("img1").style.opacity= j; } else { j=0.4; window.clearInterval(); document.getElementById("img1").src = "images/"+2+".jpg"; setInterval("showN()",40); } } function showN() { if(j<1) { document.getElementById("img1").style.opacity= j; j=0.1 + j; } else { window.clearInterval(); document.getElementById("img1").style.opacity= 1; } } function fadeI() { j=j-10 if(j>40) { document.getElementById("img1").style.filter ="alpha(opacity="+j+")"; } else { j=40; window.clearInterval(fI); document.getElementById("img1").src = "images/2.jpg"; var sI = setInterval("showI()",40); } } function showI() { if(j<100) { document.getElementById("img1").style.filter ="alpha(opacity="+j+")"; j=10 + j; } else { document.getElementById("img1").style.filter ="alpha(opacity="+100+")"; window.clearInterval(sI); } } 
it gives unwanted flicks on IE coz clearInterval did not work.....When you use setInterval you are supposed to set it to a variable, which becomes its ID, in effect - eg instead of just writing setInterval("showN()",40); as you have, you should write var IntervalID = setInterval("showN()",40); Then, later when you want to clear it, you must refer to that ID: clearInterval(intervalID); Edit: screw jQuery. Never found a use for it yet. DIY, always.
-
When you use setInterval you are supposed to set it to a variable, which becomes its ID, in effect - eg instead of just writing setInterval("showN()",40); as you have, you should write var IntervalID = setInterval("showN()",40); Then, later when you want to clear it, you must refer to that ID: clearInterval(intervalID); Edit: screw jQuery. Never found a use for it yet. DIY, always.
NeverHeardOfMe wrote:
screw jQuery. Never found a use for it yet. DIY, always.
That's what we need, more people who refuse to learn and espouse the "always been done that way" dictum. :rolleyes:
I know the language. I've read a book. - _Madmatt
-
NeverHeardOfMe wrote:
screw jQuery. Never found a use for it yet. DIY, always.
That's what we need, more people who refuse to learn and espouse the "always been done that way" dictum. :rolleyes:
I know the language. I've read a book. - _Madmatt
Not at all - my "objection" to the likes of jQuery is precicely that it *stops* one from learning - it's just a box of magic tricks and turns you into a dancing dog. I prefer to try and learn how to do things myself. Of course the reducto ad absurdum of this argument is that we should all go back to coding in machine language, and I am aware of that and the sillines of re-inventing the wheel. Nevertheless, I do feel there is a certian merit to my position - how often do we see questions asked here from people who have clearly learned a few "tricks" but have absolutely no real understanding of what they asking about?
-
Not at all - my "objection" to the likes of jQuery is precicely that it *stops* one from learning - it's just a box of magic tricks and turns you into a dancing dog. I prefer to try and learn how to do things myself. Of course the reducto ad absurdum of this argument is that we should all go back to coding in machine language, and I am aware of that and the sillines of re-inventing the wheel. Nevertheless, I do feel there is a certian merit to my position - how often do we see questions asked here from people who have clearly learned a few "tricks" but have absolutely no real understanding of what they asking about?
JQuery is not a black box, you have the full source code available to actually research and learn. With .NET Reflector I'm often looking at Microsoft's code to see how something was done and learning. You're argument is a bit weak but not worth the effort to drag out.
I know the language. I've read a book. - _Madmatt
-
When you use setInterval you are supposed to set it to a variable, which becomes its ID, in effect - eg instead of just writing setInterval("showN()",40); as you have, you should write var IntervalID = setInterval("showN()",40); Then, later when you want to clear it, you must refer to that ID: clearInterval(intervalID); Edit: screw jQuery. Never found a use for it yet. DIY, always.
I modified da code and put var ID... = setInterval(....)..., but now it says da ID i gave is unidentified by browsers(both IE and Firefox).....
window.onload=inItAll; var j=0; var N=2; function inItAll() { document.getElementById("img1").onclick=click; } function click() { if(navigator.appName=="Netscape") { j=0.9; var IntervalIDN1 = setInterval("fadeN()",40); //for firefox } else { j=90; var IntervalIDI1 = setInterval("fadeI()",40); //for IE } } function fadeN() //for Firefox { j=j-0.1 if(j>0.4) { document.getElementById("img1").style.opacity= j; } else { j=0.4; window.clearInterval(IntervalIDN1); document.getElementById("img1").src = "images/"+N+".jpg"; var IntervalIDN2 = setInterval("showN()",40); } } function showN() //for firefox { if(j<1) { document.getElementById("img1").style.opacity= j; j=0.1 + j; } else { window.clearInterval(IntervalIDN2); document.getElementById("img1").style.opacity= 1; } } function fadeI() //for IE { j=j-10 if(j>40) { document.getElementById("img1").style.filter ="alpha(opacity="+j+")"; } else { j=40; window.clearInterval(IntervalIDI1); document.getElementById("img1").src = "images/2.jpg"; var IntervalIDI2 = setInterval("showI()",40); } } function showI() //for IE { if(j<100) { document.getElementById("img1").style.filter ="alpha(opacity="+j+")"; j=10 + j; } else { document.getElementById("img1").style.filter ="alpha(opacity="+100+")"; window.clearInterval(IntervalIDI2); } }
if i remove ids it works perfectly on Firefox but not on IE.... -
I modified da code and put var ID... = setInterval(....)..., but now it says da ID i gave is unidentified by browsers(both IE and Firefox).....
window.onload=inItAll; var j=0; var N=2; function inItAll() { document.getElementById("img1").onclick=click; } function click() { if(navigator.appName=="Netscape") { j=0.9; var IntervalIDN1 = setInterval("fadeN()",40); //for firefox } else { j=90; var IntervalIDI1 = setInterval("fadeI()",40); //for IE } } function fadeN() //for Firefox { j=j-0.1 if(j>0.4) { document.getElementById("img1").style.opacity= j; } else { j=0.4; window.clearInterval(IntervalIDN1); document.getElementById("img1").src = "images/"+N+".jpg"; var IntervalIDN2 = setInterval("showN()",40); } } function showN() //for firefox { if(j<1) { document.getElementById("img1").style.opacity= j; j=0.1 + j; } else { window.clearInterval(IntervalIDN2); document.getElementById("img1").style.opacity= 1; } } function fadeI() //for IE { j=j-10 if(j>40) { document.getElementById("img1").style.filter ="alpha(opacity="+j+")"; } else { j=40; window.clearInterval(IntervalIDI1); document.getElementById("img1").src = "images/2.jpg"; var IntervalIDI2 = setInterval("showI()",40); } } function showI() //for IE { if(j<100) { document.getElementById("img1").style.filter ="alpha(opacity="+j+")"; j=10 + j; } else { document.getElementById("img1").style.filter ="alpha(opacity="+100+")"; window.clearInterval(IntervalIDI2); } }
if i remove ids it works perfectly on Firefox but not on IE....well you need to define the var IntervalID outside of the functions (so that it is globally accessible to all), and then justs et it within var IntervalID; ... function XYZ () { IntervalID = ... }
-
well you need to define the var IntervalID outside of the functions (so that it is globally accessible to all), and then justs et it within var IntervalID; ... function XYZ () { IntervalID = ... }
Thnx a lot!!! REPS!! ++++++ can u plz look through http://www.codeproject.com/Messages/3587075/onmouseorver-for-child-element.aspx[^]