有3中方法可以彈出子窗口:傳值的關鍵是在子窗口中如何獲取父窗口對象
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可以通過var wind=self.opener;來獲取父窗口對象,這樣就方便在父子
窗口中傳值
2、window.showModelessDialog
window.showModelessDialog('Untitled.html',this);或
window.showModelessDialog('Untitled.html',window);
在'Untitled.htm可以通過var wind=window.dialogArguments;來獲取父窗口對象,這樣就方便在父子窗口中傳值
3、window.showModalDialog [此方法彈出的窗口始終獲取焦點]
window.showModalDialog('Untitled.html',this);或
window.showModalDialog('Untitled.html',window);
在'Untitled.htm可以通過var wind=window.dialogArguments;來獲取父窗口對象,這樣就方便在父子窗口中傳值
除了上面說的3中方法,利用parent.window.returnValue也可以從子窗口向父窗口傳值
附:彈出窗口各個參數的涵義
'title' 彈出窗口的標題
height 彈出窗口的高度
width 彈出窗口的寬度
top 彈出窗口與屏幕上方的距離
left 彈出窗口與屏幕左側的距離
toolbar=no 是否顯示工具欄,如果顯示則為yes
menubar=no 是否顯示菜單欄,如果顯示則為yes
scrollbars=no 是否顯示滾動條,如果顯示則為yes
location=no 是否顯示地址欄,如果顯示則為yes
status=no 是否顯示狀態欄,如果顯示則為yes
resizable=no 是否允許改變窗口大小,如果允許則為yes