var timer = setInterval(function(){ var obj = document.getElementById('someObject'); if (obj) { clearTimeout(timer); } }, 50);