本文介绍了Chrome 37+模态对话框returnValue的解决方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个父调用者页面和一个模态页面,当模态页面关闭时,调用者页面会从弹出模态页面获取returnValue.即使旧版本的Chrome的showModalDialog()始终返回未定义,也有许多解决方法[ javascript-showModalDialog在Chrome中不返回值.

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.

但是现在,Chrome37 +中的window.showModalDialog()在设计上已弃用[ http://blog.chromium.org/2014/07/disabling-showmodaldialog.html] ,那些获取弹出窗口的returnValue的解决方法不再起作用.

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.

比我尝试过的window.open(),但是window.open的行为与showModalDialog完全不同,并且获取正确的returnValue(因为window.open()是异步的)并不容易.

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?

推荐答案

您可以使用 jQuery模式对话框对话框

jQuery模式对话框示例

$( ".selector" ).dialog({
    close: function( event, ui ) {
        alert('dialog closed');
        return;
    }
});

Fancybox框架

Fancybox示例

$(".fancybox").fancybox({
    afterClose : function() {
        alert('dialog closed');
        return;
    }
});

两个框架都提供了回调处理程序,因此您可以存储值或将值传递给其他函数...

Both frameworks provide callback handlers so that you can store or pass values to other functions...

这篇关于Chrome 37+模态对话框returnValue的解决方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 01:20