您的位置:首页 > 运维架构

window.opener 的用法

2017-02-08 08:49 381 查看
在不使用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()" />
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  window opener