window.opener 的用法

在不使用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"  οnclick="myclose()" />
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值