JS 用window.open()函數(shù),父級頁面如何取到子級頁面的返回值
window.open("sUrl","sName","sFeature","bReplace");
window.open 返回為對象,返回對新的window對象的引用
----------------------------------------------------------------------------------------------------------------------------------------------------------
方法:
1: 在父級頁面 test.aspx 的點(diǎn)擊<input type="button" id="btnShow" onclick="showItem();" value="顯示子窗體"/>按鈕觸發(fā) ,然后 :
<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的點(diǎn)擊<input type="button" id="btnSelect" onclick="check();" value="選擇"/> 按鈕觸發(fā),然后:
<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個控件就可以得到子級頁面的返回值。
|
|