2009年4月7日 星期二

javascript & document.write

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

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

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

沒有留言: