Simple Heartbeat Timer

//----- HEARTBEAT TIMER -----
function heartbeat_timer_tick() {

setInterval('heartbeat_timer_tick()', 1000 );		 //Time in mS

Note that if the web browser tab is put in the background values of setInterval < 1000 will be changed to 1000 by browsers such as chrome to improve performance for the active tab.

A Timer You Can Stop

//----- TIMER -----
var my_timer_count = 10;
var my_timer = setInterval('my_timer_tick()', 1000);		 //Time in mS

function my_timer_tick() {
	my_timer_count = my_timer_count - 1;
	if (my_timer_count <= 0)
		document.getElementById('my_message').innerHTML = "Competed";
		clearInterval(my_timer);		//Stop the timer
	document.getElementById('my_message').innerHTML = "Seconds to go: " + my_timer_count;



Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.


Your email address will not be published. Required fields are marked *