簡體   English   中英

當使用window.open並將HTML直接寫入新頁面時,如何讓瀏覽器知道頁面已完成“加載”?

[英]How can I make the browser know that the page has finished “loading” when using window.open and writing HTML directly to the new page?

Codepen的示例代碼(警告 - 在加載時打開一個新窗口)。

示例代碼:

var exampleWin = window.open("about:blank", "example");
var docMarkup = "<!doctype html><html><head><title>test</title></head>" + 
"<body><p>Why is the browser still transferring data? How can I tell it to stop?</p></body></html>";
exampleWin.document.write(docMarkup);

它工作正常,除了新打開的窗口讓瀏覽器加載微調器永遠運行。 如果我在新打開的頁面上按停止並刷新,則微調器停止。

如何告訴頁面沒有更多數據進入並使微調器停止?

編輯:在Firefox中

調用document.close

exampleWin.document.close();

...將關閉document.write寫入的輸出流,以便瀏覽器知道它已完成。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM