Home  >  Article  >  Web Front-end  >  Solution to showModalDialog returning Null in Google Chrome_javascript skills

Solution to showModalDialog returning Null in Google Chrome_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:12:131274browse

The return value of showModalDialog can be obtained under IE and Firefox, but it will return Null under Google Chrome. The solution is introduced below

Parent page:

Copy code The code is as follows:

function openwindows(){
var obj = new Object();

// Open the modal subform and get the return value
var retval = window.showModalDialog("ordervideo.jsp?rderIds=" "0010,0020,0030",obj,"dialogWidth=500px;dialogHeight=500px");

//for chrome
if(retval == undefined) {
retval = window.returnValue;
}
alert(retval);
}

Subpage:
Copy code The code is as follows:

function onload() {

//for chrome
if(window.opener != undefined) { //The value of window.opener is not empty under Google Chrome, but is undefined under IE/Firefox. This determines whether it is Google Chrome
window.opener.returnValue = flag; //The method of assigning a return value under Google Chrome window.opener.close(); //This must be closed once, otherwise the following window will be executed .close() cannot close the pop-up window, because the pop-up window under Google Chrome is a new window
}

else {
window.returnValue=flag; //This assignment method is compatible with IE/ Firefox, but not Google Chrome
}
window.close();

}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn