JS父页面获取子页面返回值

 1 父页面
 2 <html>
 3 <head>
 4     <title>无标题页</title>
 5     <script language="javascript" type="text/javascript">
 6           function opendialog1()
 7      {
 8          var someValue=window.showModalDialog("b.html","","dialogWidth=500px;dialogHeight=500px;status=no;help=no;scrollbars=no");
 9          document.form1.p1t.value=someValue;
10      }
11 
12     </script>
13 </head>
14 <body>
15     <form name="form1" action="#">
16         <input type="text" name="p1t">
17         <input type="button" value="打开对话框" onclick="opendialog1()">
18     </form>
19 </body>
20 </html>
21 子页面
22 <html>
23 <head>
24     <title>无标题页</title>
25     <script language="javascript" type="text/javascript">
26     function a(wname)
27     {
28      parent.window.returnValue=wname;  //父窗口就是上一个页面
29    window.close();
30     }
31   </script>
32 </head>
33 <body>
34     <form name="form1" action=""> 
35         <input type="button" value="传值" onclick="return a('hello')">
36     </form>
37 </body>
38 </html> 

 

posted @ 2012-10-08 17:36  Seaurl  阅读(1399)  评论(0编辑  收藏  举报