iframe 父窗口和子窗口的调用方法

 

  test.htm

 1 <html xmlns="http://www.w3.org/1999/xhtml" >
 2 <HEAD> 
 3 <TITLE> Test Page </TITLE> 
 4 <!--<script src="prototype-1.4.0.js"></script> -->
 5 <script language="javascript"> 
 6 function show(){ 
 7         window.parent.frames["frame_test"].document.getElementById("myH1").innerHTML = "http://www.pint.com"
 8 
 9 
10 </script> 
11 </HEAD>
12 <BODY> 
13 <iframe height="350"  width="600" src="frame_test.htm"  name="frame_test"></iframe> 
14 <form action="" method="post"> 
15    <input name="haha" id="haha" type="text" maxlength="30" value="haha"/><br /> 
16    <textarea cols="50" rows="5" id="getAttributeMethod"></textarea> 
17    <input type="button" onClick="show();" value="提交"/>
18 </form> 
19 <h1 id="myH1">d</h1> 
20 </BODY> 
21 </HTML> 
22 

 

  frame_test.htm

 1 <html xmlns="http://www.w3.org/1999/xhtml"> 
 2 <head> 
 3 <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
 4 <title>无标题文档</title> 
 5 </head> 
 6 <script language="javascript"> 
 7 function show(){ 
 8         parent.document.getElementById("myH1").innerHTML = 
 9 "http://www.adsf.com"
10 
11 
12 
13 
14 
15 </script> 
16 <body> 
17 <h1 id="myH1">ha</h1> 
18 <form action="" method="post"> 
19 <input name="abc" id="abc" type="text" maxlength="30" value="abc" /><br 
20 /> 
21 <textarea cols="50" rows="10" id="text"></textarea> <br /> 
22 <input type="button" value="提交" onclick="show();"/> 
23 </form> 
24 </body> 
25 </html> 
posted @ 2008-08-19 15:05  老白先生  阅读(1652)  评论(0编辑  收藏  举报