Solved

reset setTimeout

Posted on 2002-03-17
3
2,226 Views
Last Modified: 2012-06-27
I am using this javascript code:

function delayhidemenu() {
     setTimeout("hideall()",5000)
}

This code will hide some html code after 5 seconds.
It works fine.

But is it possible to reset/disable the settimeout after it has been set. I use the code when I move the mouse from a link -> like this: onmouseout="delayhidemenu()".

However when I go over the link again in the 5 seconds the html text will be still hidden after the 5 seconds!
That is not what I want it to be!

Can this be done?
0
Comment
Question by:draco51
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 6874399
set your timeout like this:


   var myTimoutID = setTimeout("hideall()",5000);



then clear it like this:

   clearTimeout(myTimoutID);

0
 
LVL 33

Expert Comment

by:knightEknight
ID: 6874404
... just make sure that the variable myTimeoutID is global in scope (i.e., not local to the function that calls setTimeout).
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 200 total points
ID: 6874422
like this:


var myTimeoutID;

function delayhidemenu() {
    if (myTimeoutID)
       clearTimeout(myTimeoutID);
    myTimeoutID = setTimeout("hideall()",5000);
}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question