本文主要讨论 window.showModalDialog 方式弹出窗口回传值给主窗口
主窗口中的函数
sub subname1
dim returnvalue
returnvalue=window.showModalDialog("namelist.asp","","dialogheight:380px;dialogtop:100px;dialogleft:100px;dialogwidth:100px;toolbar:no;menubar:no;scrollbars:no;resizable:no;location:no;status:no;")
form1.name.value=returnvalue
end sub
弹出窗口中:
sub choosename()
window.returnvalue=form1.name.value '回传值
window.close '关闭弹出窗口
end sub
需要注意的是,不能采用 window.opener 来获得主窗口
以下摘自《microsoft Dhtml html & Css reference》中对window.showModalDialog返回值的说明:
Return Value
Variant. Returns the value of the returnValue property as set by the window of the document specified in sURL.
参看opener的说明:
Sets or retrieves a reference to the window that created the current window.
window.opener [ =sWindow ]
Possible Values: sWindow String that specifies the window reference.
The property is read/write with no default value.