实验
<html> <body> <h1> hi, this is a.html, frame below show b.html </h1> <iframe src="http://localhost/b.html"></iframe> <script type="text/javascript"> window.onload = function(){ console.log("a.html loaded"); var frame = document.getElementsByTagName("iframe"); console.log("frame src="+frame[0].src); var binput = frame[0].contentDocument.getElementById("binput"); console.log("b.html binput value="+binput.value); } </script> </body> </html>
<html> <body> <h1> hi, this is b.html. this page call by localhost domain. </h1> <input id="binput" value="binput"/> </body> </html>
原文:http://www.cnblogs.com/lightsong/p/3920935.html