欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript showModalDialog,open取得父窗口的方法

 更新時(shí)間:2010年03月10日 20:03:37   作者:  
showModalDialog,open取得父窗口的代碼,需要的朋友可以參考下。
通常使用window.open的方式開啟新窗口的話
要取得父窗口的控件,可以用window.opener來取得父窗口
然而如果使用showModalDialog的話...卻無效
如果有需要的話,需要修改開啟的語法以及showModalDialog中的語法
開啟語法第2個(gè)參數(shù)請(qǐng)下self,范例如下
var rc=window.showModalDialog(strURL,self,sFeatures);
然后接著就是呼叫父窗口的語法
var pWindow=window.dialogArguments;
這樣就可以取得父窗口的window對(duì)象控制了。例如:
window.dialogArguments.document.getElementsByName("processId")[0].value;

js中 opener和parent的區(qū)別

opener即誰打開我的,比如A頁面利用window.open彈出了B頁面窗口,那么A頁面所在窗口就是B頁面的
opener,在B頁面通過opener對(duì)象可以訪問A頁面。
parent表示父窗口,比如一個(gè)A頁面利用iframe或frame調(diào)用B頁面,那么A頁面所在窗口就是B頁面的
parent。
在JS中,window.opener只是對(duì)彈出窗口的母窗口的一個(gè)引用。比如:
a.html中,通過點(diǎn)擊按鈕等方式window.open出一個(gè)新的窗口b.html。那么在b.html中,就可以通過
window.opener(省略寫為opener)來引用a.html,包括a.html的document等對(duì)象,操作a.html的內(nèi)容。
假如這個(gè)引用失敗,那么將返回null。所以在調(diào)用opener的對(duì)象前,要先判斷對(duì)象是否為null,否則會(huì)
出現(xiàn)“對(duì)象為空或者不存在”的JS錯(cuò)誤。
復(fù)制代碼 代碼如下:

<html>
<body>
<form. name=form1>
<input type=text name=inpu >
<input type=button >
</form>
</body>
</html>

back2opener.html
復(fù)制代碼 代碼如下:

<html>
<body>
<form. name=form1>
<input type=text name=inpu >
<a class=under href=# >添加</a>
</form>
</body>
</html>

window.opener 返回的是創(chuàng)建當(dāng)前窗口的那個(gè)窗口的引用,比如點(diǎn)擊了a.htm上的一個(gè)鏈接而打開了
b.htm,然后我們打算在b.htm上輸入一個(gè)值然后賦予a.htm上的一個(gè)id為“name”的textbox中,就可以
寫為:
window.opener.document.getElementById("name").value = "輸入的數(shù)據(jù)";

相關(guān)文章

最新評(píng)論