毎秒iframeを更新するスクリプトを作成しようとしています。これは私が今までに持っているもので、何らかの理由で少し時間がかかり、14541 +/- 50程度の数字が表示されます。 「何か」と「何か」という言葉も決して画面に表示されません。javascriptのタイムドループでsetTimeoutが機能しない
無限ループや何かに対するブラウザの保護機能が組み込まれているため、14541で停止していますか?タイマーが正しく機能しないのはなぜですか?
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();
}
これについて詳しく説明できますか?私はタイマーを修正し、何とか0で動作してから、新しいページにリダイレクトして何か他のものを何度も印刷し、増加する数字を表示するポップアップが表示されます。 – mavix