DevelopPHP
home Forum gear home

Libraries book

HTML Library CSS Library JavaScript Library PHP Library

Videosbook

PHP and MySQL JavaScript HTML and CSS Vector and 3D Flash Actionscript Android Dev Miscellaneous

Resourcesbook

Website Hosting
window.clearInterval Method Javascript DOM   Share / Like

The clearInterval method of the window object is used to stop a time interval based function from running. setInterval() initiates the timed functionality, while clearInterval() stops it from further processing.

SYNTAX window.clearInterval( interval )

Parameters

interval
The identifier that represents the setInterval() that you wish to target.

 

Javascript CODE EXAMPLE
<!DOCTYPE html>
<html>
<body>
<h1 id="status">0</h1>
<button onclick="clearInt();">Stop the timed function</button>
<script type="text/javascript">
var seconds = 0;
var myInterval = window.setInterval(timedFunction, 1000);
function timedFunction() {
    seconds++;
    document.getElementById("status").innerHTML = seconds;
}
function clearInt() {
    window.clearInterval(myInterval);
}
</script>
</body>
</html>
 

0

 

TIP: You can choose to not apply the reference for the "window" object since it is implied if not specified. window.clearInterval(myInterval); works the same as clearInterval(myInterval);

 

Related Material

setTimeout()
clearTimeout()

Home   •   Terms of Use   •   Developer Forums   •   T-Shirts   •   RSS   •   Classroom Chalkboard   •   Donate   •   Top ↑
Popular In PHP / MySQL E-Commerce Store Production
Social Network Website Building
Image Upload / Photo Processing
CMS Software Programming
Mass Email Systems
Magic XML Data
Search Programming
Popular In JavaScript JSON Programming
Ajax Programming
Animating Elements
WYSIWYG Programming
Date/Time Programming
DOM Scripting
Object Reference
Popular In HTML Canvas Element
New Form Elements
Audio Element
Video Element
Drag and Drop
Event Handling
Element Grouping
Popular In CSS Custom Font Embedding
Dynamic Fit Backgrounds
Theatre Mode
Box Overlays
CSS Level 1 Properties
CSS Level 2 Properties
CSS Level 3 Properties
©2013 DevelopPHP   |   Navigate to related domains HTML5