I'm trying to write a script to update an iframe every second. This is what I have so far, and for some reason it loads for a little while and then displays the number 14541 +/- 50 or so. The words "something" and "something else" also never appear on the screen.
Is it stopping at 14541 because of some built-in browser safeguard against infinite loops or something? Why is the timer not working correctly?
var c = 0;
var t;
timer();
document.write("something");
function timer(){
if(t) { window.clearTimeout(t) }
update_preview();
c++;
t=setTimeout(timer(), 1000);
document.write("something else");
}
function update_preview(){
prev = window.open("","preview");
prev.document.open();
prev.document.writeln("<html><head><title>live preview window</title></head><body>");
prev.document.writeln(c);
prev.document.writeln("</body></html>");
prev.document.close();
}