workaround of Chrome 37+ modal dialog returnValue

匆匆过客 提交于 2019-12-25 03:37:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!