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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With