Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8576475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:55:54+00:00 2026-06-11T19:55:54+00:00

The following Javascript code works in all browsers except IE9. What’s the fix? setTimeout(‘doSomething();clearTimeout();’,500);

  • 0

The following Javascript code works in all browsers except IE9. What’s the fix?

setTimeout('doSomething();clearTimeout();',500);

The debugger says that it’s expecting me to pass an ID number to clearTimeout(), when all I’m doing is clearing all timeouts.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:55:55+00:00Added an answer on June 11, 2026 at 7:55 pm

    As others have said, clearTimeout() without any arguments doesn’t do anything. clearTimeout() requires you to specify which timeout you want to clear. This applies in all browsers. Maybe only IE is reporting the error, but it’s causing a problem in all of them.

    Perhaps the reason you’re calling clearTimeout() is that you think the setTimeout() needs to be cleared in case it keeps getting called? This is incorrect — setTimeout() causes its code to be called just once, after the given amount of time.

    Therefore, since you’re trying to clear the timeout after it’s already been triggered, there’s nothing to clear anyway.

    There is a separate command called setInterval() which does trigger a repeating timeout. This would need to be cleared to stop it calling over and over and over, but it’s generally considered to be a bad idea to use setInterval() anyway, so I won’t dwell on it too much here.

    The other thing you should do is avoid calling setInterval with a string parameter. Just specify the function you want to call directly, instead.

    In short, your code should look like this:

    setTimeout(doSomething,500);
    

    That should be sufficient for your example to work fine in all browsers.

    As I said, you don’t need to clear the timeout in your case, but in case you do need to clear it in another instance, you would need to have setTimeout (or setInterval) return a value. This value is a reference object to the timer, and this reference is what you need to pass into clearTimeout.

    ie:

    var timer;
    ....
    timer = setTimeout(doSomething,500);
    ....
    ....
    //something happened, I need to cancel the timeout:
    clearTimeout(timer);
    

    Hope that helps clear things up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following code which works perfectly in all browsers except Chrome and
Consider the following code which works great in all modern browsers. CSS: .container {
I have the following Javascript code that works perfectly: $(document).ready(function() { $(#Select1).setDefault(); $(#Select2).setDefault(); $(#Select3).setDefault();
I have some JavaScript code that works in IE containing the following: myElement.innerText =
Following this code my button works perfectly: http://twitter.github.com/bootstrap/javascript.html#modals Fades and everything. I want to
I have the following chunk of code. It works perfectly. <div id=restaurant_locations></div> <script type=text/javascript>
The following code works only in Chrome. I need it to run on all
I have a web app that works fine from all browsers (IE9, Firefox, Chrome,
Javascript objects can be used as maps. The following all is valid code: var
I don't understand this at all. Here is some Javascript code that works in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.