parentfrm.html
1<html>
2<head>
3<title>父窗口</title>
4<script language="javascript">
5<!--
6var wName;
7function fnOpen()
8{
9wName=window.showModalDialog("frmChild.html",sendFromParent.value);
10}
11//-->
12</script>
13</head>
14<body>
15请输入要传递给子窗口的数据信息<input name="sendFromParent" type="text"/><input name="btnSendMsg" onclick="fnOpen();" type="button" value="发送"/>
16<br/>
17从子窗口传递给父窗口的数据为:<input name="getFromChildMsg" type="text"/>
18<div id="oDiv"></div>
19</body>
20</html>
childfrm.html
1<html>
2<head>
3<title>子窗口</title>
4<script language="javascript">
5<!--
6var getFromParent=window.dialogArguments;
7var showGetMsg="接收到父窗口的信息为:" + getFromParent;
8document.write(showGetMsg);
9
10function sendFromChild()
11{
12opener.oDiv.innerText=txtSendFromChildMsg.value;
13}
14//-->
15</script>
16</head>
17<body>
18<br/>
19子窗口传递给父窗口的数据为:<input name="txtSendFromChildMsg" type="text"/><input onclick="sendFromChild();" type="button" value="发送"/>
20</body>
21</html>
为什么opener.oDiv.innerText=txtSendFromChildMsg.value;这句话报错呢?有什么办法能得到吗?
---------------------------------------------------------------
showModalDialol打开的窗口本身就不是跟打开它的窗口是父子关系吧
---------------------------------------------------------------
==========================================================
1<html>
2<head>
3<title>父窗口</title>
4<script language="javascript">
5<!--
6var wName;
7function fnOpen()
8{
9wName=window.open("childfrm.html?"+sendFromParent.value);
10}
11//-->
12</script>
13</head>
14<body>
15请输入要传递给子窗口的数据信息<input id="sendFromParent" type="text"/><input name="btnSendMsg" onclick="fnOpen();" type="button" value="发送"/>
16<br/>
17从子窗口传递给父窗口的数据为:<input id="getFromChildMsg" type="text"/>
18<div id="oDiv"></div>
19</body>
20</html>
============================================================
1<html>
2<head>
3<title>子窗口</title>
4<script language="javascript">
5<!--
6var getFromParent=location.search;
7var showGetMsg="接收到父窗口的信息为:" + getFromParent;
8document.write(showGetMsg);
9
10function sendFromChild()
11{
12opener.getFromChildMsg.value=txtSendFromChildMsg.value
13}
14//-->
15</script>
16</head>
17<body>
18<br/>
19子窗口传递给父窗口的数据为:<input name="txtSendFromChildMsg" type="text"/><input onclick="sendFromChild();" type="button" value="发送"/>
20</body>
21</html>
---------------------------------------------------------------
1.
function fnOpen()
{
oDiv.innerText=window.showModalDialog("frmChild.html",sendFromParent.value);
}
2.
function sendFromChild()
{
window.returnValue=txtSendFromChildMsg.value;
window.close();
}
---------------------------------------------------------------
测试通过
frmParent.html
1<html>
2<head>
3<title>父窗口</title>
4<script language="javascript">
5<!--
6var wName;
7function fnOpen()
8{
9wName=window.showModalDialog("frmChild.html",sendFromParent.value);
10alert(wName);
11oDiv.innerText=wName;
12}
13//-->
14</script>
15</head>
16<body>
17请输入要传递给子窗口的数据信息<input name="sendFromParent" type="text"/><input name="btnSendMsg" onclick="fnOpen();" type="button" value="发送"/>
18<br/>
19从子窗口传递给父窗口的数据为:<input name="getFromChildMsg" type="text"/>
20<span id="oDiv">asdf</span>
21</body>
22</html>
frmChild.htm
1<html>
2<head>
3<title>子窗口</title>
4<script language="javascript">
5<!--
6var getFromParent=window.dialogArguments;
7var showGetMsg="接收到父窗口的信息为:" + getFromParent;
8document.write(showGetMsg);
9
10function sendFromChild()
11{ alert(txtSendFromChildMsg.value);
12window.returnValue =txtSendFromChildMsg.value;
13window.close();
14}
15//-->
16</script>
17</head>
18<body>
19<br/>
20子窗口传递给父窗口的数据为:<input name="txtSendFromChildMsg" type="text"/><input onclick="sendFromChild();" type="button" value="发送"/>
21</body>
22</html>