Created
September 20, 2012 08:55
-
-
Save s-hiroshi/3754750 to your computer and use it in GitHub Desktop.
JavaScript > iframe sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="utf-8"> | |
<title>インラインフレームのテスト</title> | |
</head> | |
<body> | |
<iframe width="200" id="frame" height="150" src="sample.html"> | |
テスト | |
</iframe> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function($) { | |
var frame = document.getElementById('frame'); | |
// frameがドキュメントの読み込みを完了してからfram内要素の処理を行うためonloadイベント使う。 | |
frame.onload = function() { | |
var form = frame.contentWindow.document.getElementById('form'); | |
var submit = (function(elem) { | |
return function() { | |
window.alert('Frame Test'); | |
return false; | |
}; | |
}(form)); | |
form.onsubmit = submit; | |
}; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<title>インライン</title> | |
</head> | |
<body> | |
<form id="form" action="#" method="POST"> | |
<input type="submit" value="アラート"> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment