现在的位置: 首页 > 综合 > 正文

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

2013年09月18日 ⁄ 综合 ⁄ 共 865字 ⁄ 字号 评论关闭

 转自 :http://blog.csdn.net/yemy/archive/2006/10/25/1351413.aspx

父页面
<html>
<head>
    <title>无标题页</title>
    <script language="javascript" type="text/javascript">
          function opendialog1()
     {
         var someValue=window.showModalDialog("b.html","","dialogWidth=500px;dialogHeight=500px;status=no;help=no;scrollbars=no");
         document.form1.p1t.value=someValue;
     }

    </script>
</head>
<body>
    <form name="form1" action="#">
        <input type="text" name="p1t">
        <input type="button"
value
="打开对话框" onclick="opendialog1()">
    </form>
</body>
</html>
子页面
<html>
<head>
    <title>无标题页</title>
    <script language="javascript" type="text/javascript">
    function a(wname)
    {
     parent.window.returnValue=wname;  //父窗口就是上一个页面
   window.close();
    }
  </script>
</head>
<body>
    <form name="form1" action="">
        <input type="button"
value
="传值" onclick="return a('hello')">
    </form>
</body>
</html>

抱歉!评论已关闭.