Works:

// Create wrapper
wrapper = doc.createElement("div");
wrapper.id = 'mcBodyWrapper';
wrapper.style.display = 'none';
wrapper.style.margin = '0';

// Wrap body elements
nodes = doc.body.childNodes;
for (i=nodes.length-1; i>=0; i--) {
if (wrapper.hasChildNodes())
wrapper.insertBefore(nodes[i].cloneNode(true), wrapper.firstChild);
else
wrapper.appendChild(nodes[i].cloneNode(true));

nodes[i].parentNode.removeChild(nodes[i]);
}

// Add wrapper
doc.body.appendChild(wrapper);

Doesn't work:

// Create iframe
iframe = document.createElement("iframe");
iframe.id = "mcWinIframe";
iframe.src = document.location.href.toLowerCase().indexOf('https') == -1 ? "about:blank" : tinyMCE.settings.default_document;
iframe.width = "100%";
iframe.height = "100%";
iframe.style.margin = '0';

// Add iframe
doc.body.appendChild(iframe);

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/M4OtReMjuoA/12177