问题
in my web page, I am opening a popup window and generate the HTML for the popup using JavaScript/jQuery:
var site="<html> ............. </html>";
var popupWindow = window.open("","","menubar=0,scrollbars=0");
popupWindow.document.write(site);
The problem is, that the popup window shows "reading" in the status bar. What should I use instead of document.write()?
EDIT:
document.close();
should do the work, thanks. Unfortunately, my framework may be interfering, so it's not working for me in FF. IE works.
回答1:
You have to close the document when you'r done writing:
var site="<html> ............. </html>";
var popupWindow = window.open("","","menubar=0,scrollbars=0");
popupWindow.document.write(site);
popupWindow.document.close();
回答2:
popupWindow.document.close();
Adding this to the end will solve the issue. I have found it here before : http://p2p.wrox.com/javascript-how/36703-javascript-popup-keeps-loading.html
回答3:
You should use jQuery's append()
var win = window.open();
var popup = win.document.body;
$(popup).append('site html');
Or innerHTML
var popup = window.open();
popup.document.body.innerHTML = 'site data here';
来源:https://stackoverflow.com/questions/13646800/what-should-i-use-instead-of-document-write-for-a-popup