I'm using the method described here (https://stackoverflow.com/a/10433550/556079) to create an iframe that loads HTML that I give it rather than loading from another URL. The HTML I want to load is the entire DOM of the current page (essentially mirroring it).
Here is the code from that question linked above. This works perfectly except I need to get a lot more HTML into the iframe.
var iframe = document.createElement('iframe');
var html = '<body>Foo</body>';
document.body.appendChild(iframe);
iframe.contentWindow.document.open();
iframe.contentWindow.document.write(html);
iframe.contentWindow.document.close();
As you can see, it's loading <body>Foo</body>
into the iframe. I tried doing: var html = document;
but this did not work.
This code is being used in a Chrome extension so I only need it to work in Chrome. My reasoning for doing this is that I want to manipulate the code in the iframe. Unfortunately, Chrome does not allow local pages to talk to each other and local pages is where I'm using this Chrome extension at.
Any ideas?