首页 > 解决方案 > Outlook 加载项对话框的事件处理程序失败

问题描述

我有从 Outlook 任务窗格调用对话框的加载项。对话框正在正确加载,但即使对话框上有 messageParent 脚本,父任务窗格也没有从对话框接收任何数据。似乎父任务窗格中的事件处理程序根本没有执行。

我正在使用 Outlook 2013 以及 Outlook.com。两种环境都显示相同的行为。

这是我在父任务窗格中的代码:

var dlg;
Office.initialize = function (reason) {
    $(document).ready(function () {
        $("#btnTestDialog").click(function () {
            Office.context.ui.displayDialogAsync("https://localhost:44300/TestDialog.aspx",
                { height: 50, width: 25, displayInIframe: true },
                function (result) {
                    dlg = result.value;
                    dlg.addEventHandler(Microsoft.Office.WebExtension.EventType.DialogMessageReceived, processTestDialog);
                });
        });
    });
};

function processTestDialog(result) {
    var x = "";
    dlg.close();
}

这是我的对话框页面(TestDialog.aspx)中的代码

Office.initialize = function (reason) {
            $('#btnTest').click(passDataToTest);

            $(document).ready(function () {

            });
        };

        function passDataToTest() {
            var response = { "status": "sucess", "message": "test" };
            Office.context.ui.messageParent(JSON.stringify(response));
        }

我已经做了很多研究,在我所有的研究中都说这段代码应该可以工作,但我不知道为什么不能。

标签: outlook-web-addinsoutlook-2013

解决方案


推荐阅读