iframe参数的调用

/ 0条评论 / 0 个点赞 / 1269人阅读

页面1

<html>
<head>
<script type="text/javascript">
function getMsg(){
var el = document.getElementById("msg");
var txt = document.frames['inside'].document.getElementById('txts');
txt.value = el.value;
}
</script>
</head>
<body>
<input type="text" id="msg" />
<input type="button" onclick="getMsg()" value="button" /><br/>
<iframe name="inside" id="inside" src="1.html" cols="30%,*" height=600 width=1100 scrolling=no frameborder=yes>
</iframe>
</body>
</html>

页面2

<html>
<head>
<script type="text/javascript">
function getMsgs(){
var el = parent.document.getElementById("msg");
var txt = document.getElementById("txts");
el.value = txt.value;
}
</script>
</head>
<body>
<input type="text" id="txts" />
<input type="button" value="button" onclick="getMsgs()"
</body>
</html>

iframe参数的调用