I need to inject in an iframe window a document object that I instanciated previously, and I cannot serialize it into a string or a remote url (those are solutions proposed
Try using importNode
:
/* Change these: */
var documentToCopy = document,
iframeDocument = iframe.contentWindow.document;
/* Replace current document-element (<html>) with the new one: */
iframeDocument.replaceChild(
iframeDocument.importNode(documentToCopy.documentElement, true),
iframeDocument.documentElement
);
See https://developer.mozilla.org/en/DOM/document.importNode