1. 通过Opener方法调用父窗体方法传值


1

2

3

4

5

6

7

8

9

10

11


12


13

14

15

16

17

18

19

20

21



1

2

3

4

5


6

7


8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23



1

2

3

4

5

6

7

8

9

10

11


12

13


14

15


16

17

18

19

20

21

22

23



1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

扩展:子窗体关闭要刷新父窗体,在子窗体赋值的第一句加上opener.location= opener.location.href;
第二种:ShowModalDialog
1.window.returnValue方法传值


1

2

3


function fnOpen() {
4

5


6

7

}
8

9

10

11

12

13

14

15

16

17

18

19

20

21

22



<html>
<head>
<script type="text/javascript">
function exit()
{
window.returnValue = form1.txtreturn.value; //返回值
window.close();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
传递过来的值: <input type="text" id="txtreturn" runat ="server"/>
<input id="button" name="button" type="button" value="关闭窗口" runat ="server" onclick="exit()"/>
</div>
</form>
</body>
</html>