I m trying to create an iframe from JavaScript and fill it with arbitrary HTML, like so:
var html = <body>Foo</body> ;
var iframe = document.createElement( iframe );
iframe.src = data:text/html;charset=utf-8, + encodeURI(html);
我期待<代码>iframe,然后载有有效的窗口和文件。 然而,情况并非如此:
> console.log(iframe.contentWindow);
null
http://jsfiddle.net/TrevorBurnham/9k9Pe/>http://jsfiddle.net/TrevorBurnham/9k9Pe/
我所期待的是什么?