Codepen of the sample code (Warning - opens a new window on loading).
The sample code:
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);
It works fine, except that the newly opened window has the browser loading spinner running forever. If I press stop and refresh on the newly opened page, the spinner stops.
How can I tell the page that there is no more data coming and make the spinner stop?
EDIT: In Firefox
Call document.close
:
exampleWin.document.close();
… which will close the output stream that document.write
writes to so the browser will know it is done.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.