繁体   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