var insideLetterCount = 0; var SLEEP = 500; var TIME = 1000 * 60; onload = function () { if(insideLetterCount >0){ font.INTERVAL = setInterval (function () { (typeof font.index) === 'undefined' ? font.index = 0 : font.index++; font.style.color = [ 'red', 'black' ][font.index % 2]; if (font.index > TIME / SLEEP) { clearInterval (font.INTERVAL); delete font.index; delete font.INTERVAL; } }, SLEEP); } }