有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