window.opener 的用法

来源:互联网 发布:mac如何设置qq邮箱 编辑:程序博客网 时间:2024/05/22 17:28
在不使用window.showModalDialog 的情况下用 window.open方式 向父窗口返回值。 
例:页面AAA.htm 用 window.open方式弹出页面 BBB.htm 。 
在页面BBB.htm上选择一个值,确定关闭窗口后将选择的这个值返回到父窗口AAA.htm。 
AAA.htm得到返回的值后,给本页面上的文本框赋值。 
AAA.htm
<input id="test" name="test" />
BBB.htm
<script language="javascript">function myclose(){window.opener.document.getElementById("test").value=document.getElementById('mytest').options[document.getElementById("mytest").selectedIndex ].value;window.close();}</script>  <select id="mytest" name="mytest"> <option value="1" selected="selected">text1</option> <option value="2">text2</option> </select><input type="button"  onclick="myclose()" />
1 0
原创粉丝点击