Reach the contents of a new window.

I made a new window

var win = window.open("", "", "width=400, height=200"); 

and I want to reach my body with

 var $windowBody = $(win.document.body); 

and from there use methods like .find() , .html()

This works well in FF and Chrome , but not in IE . I also found a related post on this.

How to fix it in IE? those. how to make this work cross browser

jsFiddle - note that the close button never appears in IE.

+7
javascript jquery internet-explorer
source share
1 answer

Please use the code below 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); 
+1
source share

All Articles