Because the system should be compatible with the original IE has been used to close the method, measured by debugging, it is necessary to window.dialogarguments more than the test, otherwise easy to problem.
function Okend (vals) {
if (Vals = null) Vals = "TRUE";
if (typeof (Window.opener) = = "undefined") {
if (typeof (Window.dialogarguments)!= "undefined") {
if (window.dia logarguments && window.dialogarguments!= null) {
window.opener = window.dialogarguments;
if (window.opener && window.opener!= null) {
window.opener.ReturnValue = vals;
}
}
}
}
else {
if (window.opener && window.opener!= null) {
window.opener.ReturnValue = Vals;
}
}
Window.returnvalue = Vals;
Self.close ();
}
Return value received, only in the original IE received mode, more than a Test opener on it, as follows:
Select Change Department
function SetOrganizeTree2 () {var url= "pop-up page";
var ret = window.showmodaldialog (URL, window, "Dialogwidth=400px;dialogheight=500px;status=no;help=no;scroll=yes"; Resizable=yes; ");
if (typeof (ret) = = "undefined") {
ret = window. returnvalue;
}
if (ret) {
document.getElementById ("HidDeptCode2"). Value = RET;
document.getElementById ("Btndeptcodeadd"). Click ();
return false;
}
JS modal window return value compatibility problem perfect solution
1. When the pop-up window is opened, the window is passed as the second parameter.
var result = window.showModalDialog (URL, window, "dialogwidth=" + width + "px;dialogheight=" + height + "Px;resizable:yes; ")
if (typeof (Result) = = ' undefined ') {result
= window. returnvalue;
}
return result;
2, in the pop-up window, execute the following JS to receive the incoming window
if (typeof (Window.opener) = = ' undefined ') Window.opener = window.dialogarguments;
3, the pop-up window before closing, call the following JS assignment return value
Window.returevalue = Vals;
if (window.opener && window.opener!= null)
window.opener.ReturnValue = Vals;
Window.close ();
Principle discussion:
Chrome, the standard method, when the pop-up page does not postback, can return a value. A postback is not a normal return value. This method can be resolved.
IE standard method, sometimes unknown reason can not return the value correctly, this method can be resolved.
FF not tested in detail, should not be a problem.
The above JS modal window return value compatibility problem of the perfect solution is small to share all the content of everyone, hope to give you a reference, but also hope that we support the cloud habitat community.