今天在改公司一个老系统时,碰到了window.open()的这个语法。虽然这个方法有点老,不太用了。所以有点不清楚父级弹框如何获取子级页面返回的值。为了解决这个问题,上网搜了一下。原作者参考网址:http://blog.csdn.net/xmwangtiger/article/details/4234054
这里重点总结一下啊!
语法:window.open("sUrl","sName","sFeature","bReplace");
使用:1: 在父级页面 test.aspx 的点击<input type="button" id="btnShow" onclick="showItem();" value="显示子窗体"/>按钮触发 ,然后 :
<script language="javascript" type="text/javascript">
function showItem() {
var win = window.open("test2.aspx",null," height=300,width=450, Left=300px,Top=20px, menubar=no,titlebar=no,scrollbar=no,toolbar=no, status=no,location=no");
}
2: 在子级页面test2.aspx的点击<input type="button" id="btnSelect" onclick="check();" value="选择"/> 按钮触发,然后:
<script language="javascript" type="text/javascript">
function check() {
window.opener.document.getElementById("txtId").value=id;
window.opener.document.getElementById("txtName").value=name;
}
这样,父级页面的document.getElementById("txtId") 和 document.getElementById("txtName") 2个控件就可以得到子级页面的返回值。