<!DOCTYPE html> <iframe></iframe> <script> var iframe = document.getElementsByTagName("iframe")[0]; var doc = iframe.contentDocument; doc.open("TEXT/HTML"); doc.write("<i>foo</i>"); doc.close(); </script>