有3中方法可以彈出子窗口:傳值的關(guān)鍵是在子窗口中如何獲取父窗口對(duì)象
1、window.open
window.open('test.htm','title','height=100,width=200,top=0,left=0,toolbar=no,
menubar=no,scrollbars=no,resizable=no,location=no,status=no');
在test.htm可以通過(guò)var wind=self.opener;來(lái)獲取父窗口對(duì)象,這樣就方便在父子
窗口中傳值
2、window.showModelessDialog
window.showModelessDialog('Untitled.html',this);或
window.showModelessDialog('Untitled.html',window);
在'Untitled.htm可以通過(guò)var wind=window.dialogArguments;來(lái)獲取父窗口對(duì)象,這樣就方便在父子窗口中傳值
3、window.showModalDialog [此方法彈出的窗口始終獲取焦點(diǎn)]
window.showModalDialog('Untitled.html',this);或
window.showModalDialog('Untitled.html',window);
在'Untitled.htm可以通過(guò)var wind=window.dialogArguments;來(lái)獲取父窗口對(duì)象,這樣就方便在父子窗口中傳值
除了上面說(shuō)的3中方法,利用parent.window.returnValue也可以從子窗口向父窗口傳值
附:彈出窗口各個(gè)參數(shù)的涵義
'title' 彈出窗口的標(biāo)題
height 彈出窗口的高度
width 彈出窗口的寬度
top 彈出窗口與屏幕上方的距離
left 彈出窗口與屏幕左側(cè)的距離
toolbar=no 是否顯示工具欄,如果顯示則為yes
menubar=no 是否顯示菜單欄,如果顯示則為yes
scrollbars=no 是否顯示滾動(dòng)條,如果顯示則為yes
location=no 是否顯示地址欄,如果顯示則為yes
status=no 是否顯示狀態(tài)欄,如果顯示則為yes
resizable=no 是否允許改變窗口大小,如果允許則為yes