After solving the same problem, this is a fragment of a solution that worked in my case for IE, avoiding error SCRIPT5022. Thanks to the help of this post .
var myWindow = window.open('about:blank', 'loading...', ''); var myWindowDoc = myWindow.document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null); var myWindowBody = myWindow.document.createElementNS('http://www.w3.org/1999/xhtml', 'body'); myWindow.document.open().write('<html><head></head><body><div id="targetDiv"></div></body></html>'); myWindow.document.close(); try { myWindow.document.getElementById('targetDiv').appendChild(HTMLpayload.cloneNode(true)); } catch (e){ if (HTMLpayload.outerHTML) { myWindow.document.getElementById('targetDiv').innerHTML = HTMLpayload.outerHTML; } else { console.log(e); } }
Robert Waddell
source share