Instead of setTimeout, consider using setInterval. It will repeat automatically until you clear the interval.
setInterval(myMethod, 5000);
function myMethod( )
{
//this will repeat every 5 seconds
//you can reset counter here
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…