1. 程式人生 > >js獲取frameSet子頁面的空間

js獲取frameSet子頁面的空間

1、index.html

<html>
<head>
<title>test</title>
</head>
<body>
 <iframe width="100%" id="iframe_id" name="iframe_id" scrolling="no"
  height="650px" src="main.htm">
</body>

</html>

2、main.jsp

<html>
<frameset cols="20%,*">
 <frame name="index" id="index" src="left.htm">
 <frame name="content" src="right.htm">
</frameset>
</html>

3、left.html

<html>
<head>
<title>test123</title>
</head>
<body>
 
 <br />
 <button name='but' value='111' onclick='onc();' >測試</button>
 <script type="text/javascript">
  var onc = function(){
   alert(parent.content.getAaa("來自host.html的值"));
  };
 </script>
</body>
</html>

4、right.html

<html>
<body>
 <input id="aaa" value="來自htmlyyjc1.html的值"/>
</body>
<script>
 var getAaa = function(){
  
  return document.getElementById("aaa").value;
 };
</script>
</html>