How to start Timer in Javascript?

 Posted by vishalneeraj-24503 on 12/20/2013 | Category: JavaScript Interview questions | Views: 888 | Points: 40
Answer:

With the help of setInterval static method of window object.
We can invoke or start timer.

Syntax:-

window.setInterval("javascript function",milliseconds);

For Example:-

var str = setInterval(function(){start_timer()},3000);


function start_timer()
{
alert("Hello");
}

Then it will shown Hello message in 3 seconds.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response