代码如下:
<html>
<head>
<title>Page A</title>
<script>
var getValue=function(){
alert(window.frames['frame1'].document.getElementById('mytext').value);
}
</script>
</head>
<body> <iframe id="frame1" name="frame1" width="300" height="300" src="http://127.0.0.1/b.html"></iframe>
<form method="post">
<input type="text" id="mytext" value="I'm page A"/>
<button onclick="getValue()">获取子窗口属性</button>
</form>
</body>
</html>
<html>
<head>
<title>Page A</title>
<script>
var getValue=function(){
alert(window.frames['frame1'].document.getElementById('mytext').value);
}
</script>
</head>
<body> <iframe id="frame1" name="frame1" width="300" height="300" src="http://127.0.0.1/b.html"></iframe>
<form method="post">
<input type="text" id="mytext" value="I'm page A"/>
<button onclick="getValue()">获取子窗口属性</button>
</form>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货