setTimeout and clearTimeout

Last post 10-13-2008 8:45 AM by Bigfellahull. 2 replies.

Sort Posts:

  • setTimeout and clearTimeout

    10-12-2008, 6:45 PM
    • Member
      22 point Member
    • Bigfellahull
    • Member since 07-20-2006, 7:28 AM
    • Posts 17

    I have a question for you guys.

    I have two functions which I call on mouseover using setTimeout.

    However - if the user mouse overs another link - I want the Timeout for the old event cancelled - and set another one for a new function.

    I tried using :

     
    onmouseover="clearTimeout(time); clearTimeout(time2); var time = setTimeout(function() { closeAni('story1') }, 900); 
    var time2 = setTimeout(function() { changeStory('story1', 'nav1') }, 1200);"

     

    Just to be clear - this mouseover calls my closeAni function which fades out an image, and then calls the changeStory function which changes the image and displays it.

    However, this code doesnt seem to work. It I drag my mouse along the links - I get quick flashes of all the images. I wanted to prevent that by canceling the timeout of the old mouseover before it is excuted and only call the functions for the current mouseover event.

     Am I doing something wrong?

    Filed under: ,
  • Re: setTimeout and clearTimeout

    10-13-2008, 5:06 AM
    Answer
    • Contributor
      3,091 point Contributor
    • sameer_khanjit
    • Member since 12-10-2007, 1:06 PM
    • Indore India
    • Posts 638

     can you please create one function for all your task and call on mouse over event

    We Are Looking for .NET/PHP Projects

    Contact Details :-

     Email - sameer.khanjit@gmail.com

     Mobile no. : +91-9893795983

     View Blog

    linkedin Asp.net Group

    Don't forget to click “Mark as Answer” on the post that helped you
  • Re: setTimeout and clearTimeout

    10-13-2008, 8:45 AM
    • Member
      22 point Member
    • Bigfellahull
    • Member since 07-20-2006, 7:28 AM
    • Posts 17

    Thanks! That worked. Why did it not work when placed into the mouse over?

Page 1 of 1 (3 items)