在不使用window.showModalDialog 的情况下用 window.open方式 向父窗口返回值。
例:页面AAA.htm 用 window.open方式弹出页面 BBB.htm 。
在页面BBB.htm上选择一个值,确定关闭窗口后将选择的这个值返回到父窗口AAA.htm。
AAA.htm得到返回的值后,给本页面上的文本框赋值。
AAA.htm
例:页面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()" />
本文介绍如何利用JavaScript的window.open方法实现子窗口向父窗口传递数据,并展示了一个具体的例子,即通过下拉菜单选择值后,关闭子窗口并将所选值赋给父窗口中的文本框。
2万+

被折叠的 条评论
为什么被折叠?



