问题
I have a parent caller page and a modal page, when the modal page is closed, the caller page gets a returnValue from the popup modal page. Even older version Chrome's showModalDialog()
always returns undefined, there are many workarounds [javascript - showModalDialog not returning value in Chrome.
But now window.showModalDialog() in Chrome37+ is deprecated by design [http://blog.chromium.org/2014/07/disabling-showmodaldialog.html], those workarounds to get returnValue of a popup window do not work anymore.
Than I tried window.open()
, but window.open act quite differently from showModalDialog
, and its not easy to get the correct returnValue (since window.open()
is asynchronous).
So is there a perfect way to solve this?
回答1:
You can use the Jquery Modal Dialog Framework
JQuery Modal Dialog Example
$( ".selector" ).dialog({
close: function( event, ui ) {
alert('dialog closed');
return;
}
});
Or the Fancybox Framework
Fancybox Example
$(".fancybox").fancybox({
afterClose : function() {
alert('dialog closed');
return;
}
});
Both frameworks provide callback handlers so that you can store or pass values to other functions...
来源:https://stackoverflow.com/questions/26907100/workaround-of-chrome-37-modal-dialog-returnvalue