adds timers to deal with onbeforeunload event