Web Analytics Made Easy -
StatCounter setTimeout/setInterval? - CodingForum

Announcement

Collapse
No announcement yet.

setTimeout/setInterval?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • setTimeout/setInterval?

    Well my question is what the difference between them, and how are they easyest stopped once started?

  • #2
    Well, setTimeout executes the code once, after a given time, while setInterval executes the code at certain intervals until it is canceled.

    If you want to stop them before they execute, you use clearTimeout(timoutVariable) for timeouts and clearInterval(intervalVariable) for intervals.

    You should aways see to that you run clearInterval on an interval once you're through with it. There is no need to run clearTimeout on timeouts once you're through with it with the exception of cases where you do DOM manipulation in the timeout.
    liorean <[[email protected]]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

    Comment

    Working...
    X