iframe内のHTMLを動的に生成する
メモ
元ネタ http://webos-goodies.jp/archives/51014876.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <script type="text/javascript"> function write2frame() { var iframe = document.createElement('IFRAME'); document.getElementById('blog_test').appendChild(iframe); text = '<html><head></head><body onload="parent.hello(this)"><div id="hello"/></body></html>'; var doc = frames[frames.length - 1].document; doc.open(); doc.write(text); doc.close(); } function hello(doc) { hello = doc.document.getElementById("hello"); hello.innerHTML = "Hello!"; } </script> <meta name="Content-Type" content="text/html;charset=UTF-8" /> <title>タイトルです</title> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> </head> <body> <div id="blog_test"/> <a href="javascript:void(0)" onmousedown="write2frame()">click!</a> </body> </html>