var timer = setTimeout(Action, 5000); function Action(){ //your actions //disable the timer if (timer) { clearTimeout(timer) } }