關於 FireFox 的 Document.write


因為先前的測試發現了 FireFox 在直接使用 document.write 時會有不停載入的問題,經過 google 的搜尋,終於找出了問題所在和相關的解決方法

資料來源自 Mozilla TaiWan 網站

document.write 表示你要重寫整個頁面,所以第一個指令執行後,整個頁面已予清除,第二個指令也就不見了

另外,JS 語法也不正確,應該是
document.open();
document.write(…);
:
document.close();

如果不要清除網頁,可用:
text = document.createTextNode(“blah blah blah”);
document.body.appendChild(text);