簡體   English   中英

無法將信息發送到 Outlook 加載項中的對話框

[英]Cannot send information to dialog box in Outlook add-in

我無法向 Outlook 加載項中的對話框發送信息。 這是父級中的 Javascript 代碼:

 var url2 = window.location.origin+'/dialogbox.html'
 var dialog
 Office.context.ui.displayDialogAsync(url2, {height: 50, width: 50},
           function (asyncResult) {
               dialog.messageChild('hello from the parent', {targetOrigin: "*" })     
           });

這對messageChild命令成功完成。

子對話框中的Javascript是:

Office.onReady().then(function() {
         Office.context.ui.addHandlerAsync(
             Office.EventType.DialogParentMessageReceived,
             onMessageFromParent);
         });
        
function onMessageFromParent(arg){
     console.log(arg.message)
     }

但是,控制台中不會打印消息“來自父級的你好”。

相反,我在控制台中兩次得到以下信息:

Tracking Prevention blocked access to storage for https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js. [https://localhost:3000/commands.html?_host_Info=Outlook$Win32$16.02$en-US$$$$0]

我究竟做錯了什么? 如何將消息傳遞到對話框?

調用Office對話框API打開對話框時,會返回一個Dialog對象。 您將需要從本地對話框變量上的 asyncResult 設置對話框對象。 可以在此處文檔中找到有關 messageChild 的更多信息。

var dialog;
Office.context.ui.displayDialogAsync('https://myDomain/myDialog.html',
    function (asyncResult) {
        dialog = asyncResult.value;
        dialog.messageChild(...);
    }
);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM