JavaScript で iframe の中身を動的に書き換える方法

phi phi on javascript

表題の通り

var preview = document.getElementById("preview");  
var idoc = preview.contentDocument;  
var html = "<html><body>hoge</body></html>";

idoc.open();  
idoc.write(html);  
idoc.close();  

Runstant Demo