Skip to content

Instantly share code, notes, and snippets.

@MoChiwaki
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MoChiwaki/c5150493d73ac59354a3 to your computer and use it in GitHub Desktop.
Save MoChiwaki/c5150493d73ac59354a3 to your computer and use it in GitHub Desktop.
iframeのサンプル
// iframeの枠を作る
document.write('<iframe id="frame" name="frame" onload="test()" width="300" height="350"></iframe>');
// iframeの中身を作る
function test(){
var frame = document.getElementById("frame");
frame.contentDocument.write('<a href="http://jsfiddle.net/MoChiwaki/uhhkxsd6/32/embedded/result%2Chtml%2Cjs%2Ccss/#Result" target="_top"><img src="http://cdn1.www.st-hatena.com/users/Mo/MoChiwaki/profile.gif" /></a>');
}
// iframeの中のaタグだけ取る
function check(){
var iframesrc = document.getElementsByTagName("iframe")[0].contentDocument.getElementsByTagName("a");
return iframesrc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment