Reputation: 7805
I made a new window
var win = window.open("", "", "width=400, height=200");
and I want to reach its body with
var $windowBody = $(win.document.body);
and from there use methods like .find()
, .html()
This works good on FF & Chrome but not IE. Found also a related post to this one.
How to fix this in IE? ie, how to make this work cross browser?
jsFiddle - notice that the close button never shows up in IE.
Upvotes: 7
Views: 454
Reputation: 2151
Please use the below code to fix it in IE
var content = $('#content');
$('#open').on('click', function () {
var win = window.open("", "", "width=400, height=200");
$newWindow = $(win.document.body);
$newWindow.html(document.getElementById("content").innerHTML);
$newWindow.find('#close').on('click', function () {
win.close();
});
});
or use:
var content = $('#content');
// and then
$newWindow.html(content);
Upvotes: 1