iframe中互相调用其他页面变量
index.html:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ssss</title>
</head>
<body>
<iframe src="left.html" width="50%" height="100%"></iframe>
<iframe src="right.html" width="49%" height="100%" align="right"></iframe>
</body>
</html>
left.html:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
var lframe = 'this is left iframe';
function showright(){
alert(parent.frames[1].rframe);
}
</script>
<title>sssfde</title>
</head>
<body>
left iframe
<button onclick="showright()">show right</button>
</body>
</html>
right.html:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
var rframe = 'this is right frame';
function showleft(){
alert(parent.frames[0].lframe);
}
</script>
<title>1111</title>
</head>
<body>
right iframe
<button onclick="showleft()">show left</button>
</body>
</html>
传送:javascript 父窗口(父页面)— 子窗口 (子页面)互相调用的方法