1 打開一個新窗口
var newDoc=window.open("text/html","replace");
var txt="<html><body>Learning about the DOM is FUN!</body></html>";
newDoc.document.write(txt);
newDoc.close(); ? //該方法將關閉 open() 方法打開的文檔流,并強制地顯示出所有緩存的輸出內容。如果您使用 write() 方法動態地輸出一個文檔,必須記住當你這么做的時候要調用 close() 方法,以確保所有文檔內容都能顯示。一旦調用了 close(),就不應該再次調用 write(),因為這會隱式地調用 open() 來擦除當前文檔并開始一個新的文檔。
?
2 在文檔里更新
var newDoc=document.open("text/html","replace");
var txt="<html><body>Learning about the DOM is FUN!</body></html>";
newDoc.write(txt);
newDoc.close(); ? //同上
?