Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. clearInterval Not working on IE

clearInterval Not working on IE

Scheduled Pinned Locked Moved JavaScript
database
14 Posts 5 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Not Active

    Try using JQuery[^]. Cross platform and much less to write.


    I know the language. I've read a book. - _Madmatt

    G Offline
    G Offline
    greendragons
    wrote on last edited by
    #3

    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...

    P N D 3 Replies Last reply
    0
    • G greendragons

      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...

      P Offline
      P Offline
      phil o
      wrote on last edited by
      #4

      Mmmm... did you even try to click on the link Mark provided ? Because I'm not sure anyone is gonna help you here if, on your side, you're not able to give yourself a little effort.

      1 Reply Last reply
      0
      • G greendragons

        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...

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #5

        $("#img1).fadeIn();

        This is too difficult for you? :rolleyes:


        I know the language. I've read a book. - _Madmatt

        1 Reply Last reply
        0
        • N Not Active

          Try using JQuery[^]. Cross platform and much less to write.


          I know the language. I've read a book. - _Madmatt

          D Offline
          D Offline
          DaveAuld
          wrote on last edited by
          #6

          EDIT: OOps, sorry Mark, replied to the wrong message! ignore it.

          Dave Don't forget to rate messages!
          Find Me On: Web|Facebook|Twitter|LinkedIn

          1 Reply Last reply
          0
          • G greendragons

            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...

            D Offline
            D Offline
            DaveAuld
            wrote on last edited by
            #7

            I used JQuery and JQueryUI in my last article, it was the first time i had even looked at JQuery, let alone actual go an implement it. You should find it no problem at all, the basics are surprisingly simple.

            Dave Don't forget to rate messages!
            Find Me On: Web|Facebook|Twitter|LinkedIn

            1 Reply Last reply
            0
            • G greendragons

              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); } } ![](images/1.jpg) it gives unwanted flicks on IE coz clearInterval did not work.....

              N Offline
              N Offline
              NeverHeardOfMe
              wrote on last edited by
              #8

              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.

              N G 2 Replies Last reply
              0
              • N NeverHeardOfMe

                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.

                N Offline
                N Offline
                Not Active
                wrote on last edited by
                #9

                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

                N 1 Reply Last reply
                0
                • N Not Active

                  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

                  N Offline
                  N Offline
                  NeverHeardOfMe
                  wrote on last edited by
                  #10

                  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?

                  N 1 Reply Last reply
                  0
                  • N NeverHeardOfMe

                    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?

                    N Offline
                    N Offline
                    Not Active
                    wrote on last edited by
                    #11

                    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

                    1 Reply Last reply
                    0
                    • N NeverHeardOfMe

                      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.

                      G Offline
                      G Offline
                      greendragons
                      wrote on last edited by
                      #12

                      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....

                      N 1 Reply Last reply
                      0
                      • G greendragons

                        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....

                        N Offline
                        N Offline
                        NeverHeardOfMe
                        wrote on last edited by
                        #13

                        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 = ... }

                        G 1 Reply Last reply
                        0
                        • N NeverHeardOfMe

                          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 = ... }

                          G Offline
                          G Offline
                          greendragons
                          wrote on last edited by
                          #14

                          Thnx a lot!!! REPS!! ++++++ can u plz look through http://www.codeproject.com/Messages/3587075/onmouseorver-for-child-element.aspx[^]

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups