JS 用window.open()函數(shù),父級(jí)頁(yè)面如何取到子級(jí)頁(yè)面的返回值
window.open("sUrl","sName","sFeature","bReplace");
window.open 返回為對(duì)象,返回對(duì)新的window對(duì)象的引用
----------------------------------------------------------------------------------------------------------------------------------------------------------
方法:
1: 在父級(jí)頁(yè)面 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: 在子級(jí)頁(yè)面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; }
這樣,父級(jí)頁(yè)面的document.getElementById("txtId") 和 document.getElementById("txtName") 2個(gè)控件就可以得到子級(jí)頁(yè)面的返回值。
|
|
來(lái)自: 樹(shù)風(fēng) > 《JAVA》