My leader have solved this problem and let's see the trick.
For IE, in main window:
var result = window.showModalDialog (url,arguments,dialogsettings); alert (result);
Modaldialog, sub window:
Window.returnvalue = "abc"; window.close;
The above codes work fine in IE, we can fix to this:
In main window:
var dialog =function(p_result) {
alert (P_result);
Modaldialog, sub window:
Window.returnvalue = "abc";
__window_close ();
and add some code to fix prototype of Chrome:
window.showModalDialog =function(URL, arg, opt) {URL= URL | | ‘‘;//URL of a dialogarg = ARG | |NULL;//arguments to a dialogopt = opt | | ' dialogwidth:300px;dialogheight:200px ';//options:dialogtop;dialogleft;dialogwidth;dialogheight or CSS styles × varDialog = Top.window.document.body.appendChild (document.createelement (' dialog ')); Dialog.setattribute (' Style ', Opt.replace (/dialog/gi, '));dialog.innerhtml= ' <div id= ' Dlg-head "class=" Dlghead "><div id=" Dlg-title "' + (arg && arg.title? Arg.title:" ") + ' >< ;/div><div id= "Dlg-controlbox" ><a href= "javascript:void (0);" id= "Dlg-closebutton" class= " Controlboxbutton "></a></div></div><div id=" Dlg-body "class=" DlgBody "><iframe id=" Dialog-body "src=" ' + URL + ' "style=" border:0; width:100%; height:100%; " ></iframe></div> '; varDlgbodywin = Dialog.queryselector (' #dialog-body '). Contentwindow; Dlgbodywin.dialogarguments=Arg; Dlgbodywin.addeventlistener (' Load ',function(e) {dialog.queryselector (' #dlg-title '). InnerText =DlgBodyWin.document.title; }); Dialog.queryselector (' #dlg-closebutton '). AddEventListener (' click ',function(e) {e.preventdefault ();
Dialog.close ();
});
function
Dialog.addeventlistener (' Close ', function () {
var returnvalue = Dlgbodywin.returnvalue;
Top.window.document.body.removeChild (Dialog);
Dialog.callback (returnvalue);
});
Return
};
function __window_close () {
if (__ISGG) {//in Chrome
var dialogs = top.window.parent.document.getElementsByTagName ("dialog");
if (Dialogs.length > 0) {
Dialogs[dialogs.length-1].close ();
}
} else {
Window.close ();
}
}
Use HTML5 Dialog to implement ShowModalDialog, awesome.
How to do Chrome support ShowModalDialog