user1414745
user1414745

Reputation: 1317

what should I use instead of document.write for a popup

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.

Upvotes: 3

Views: 8151

Answers (3)

gkiely
gkiely

Reputation: 3007

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';

Upvotes: 0

Anujith
Anujith

Reputation: 9370

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

Upvotes: 0

sroes
sroes

Reputation: 15053

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();

Upvotes: 4

Related Questions