简体   繁体   English

从对话框(平均堆栈站点)向任务窗格发送消息

[英]Send a message from Dialog box (mean-stack site) to the task pane

I am trying to use Dialog API of Office addin. 我正在尝试使用Office插件的Dialog API

I can successfully open a Dialog box from my task pane by: 我可以通过以下方式从我的任务窗格中成功打开一个对话框:

$scope.openDialog = function () {
    Office.context.ui.displayDialogAsync('https://localhost:3000/home',
        function (asyncResult) {
            dialog = asyncResult.value;
            dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
        });
}

My Dialog box is a mean-stack site. 我的对话框是一个mean-stack站点。 I have added <script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script> in the index.html . 我在index.html添加了<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script> And I tried to use Office.context.ui.messageParent(true); 我试图使用Office.context.ui.messageParent(true); , it shows an error in console: ,它在控制台中显示错误: 在此输入图像描述

And I see in the doc that I don't understand quite well: 我在文档中看到我不太了解:

The Office JavaScript library is loaded in the page. Office JavaScript库已加载到页面中。 (Like any page that uses the Office JavaScript library, script for the page must assign a method to the Office.initialize property, although it can be an empty method. For details, see Initializing your add-in.) (与使用Office JavaScript库的任何页面一样,页面脚本必须为Office.initialize属性分配方法,尽管它可以是一个空方法。有关详细信息,请参阅初始化加载项。)

I also tried to add Office.initialize = function () { }; 我还尝试添加Office.initialize = function () { }; in index.html , the error is still there, and processMessage of the task pane does not seem to receive anything. index.html ,错误仍然存​​在,任务窗格的processMessage似乎没有收到任何内容。

So is there anything special I should do to my mean-stack site so that it could use messagePerent ? 那么我应该对我的mean-stack网站做些什么特别的事情,以便它可以使用messagePerent

The console error will not introduce any bad effect to the dialog. 控制台错误不会对对话框造成任何不良影响。 We already fixed it internal. 我们已经在内部修复了它。 You can just ignore this error. 你可以忽略这个错误。 Did you check whether office.context.ui.messageParent is null or undefined ? 您是否检查office.context.ui.messageParent是null还是未定义? if it is not, then the dialog has been initialized successfully. 如果不是,则对话框已成功初始化。 Then it will be only something wrong with the postMessage method, what system and browser version are you using ? 那么postMessage方法只会出现问题,你使用的是什么系统和浏览器版本? 1. If it is Win10 and latest version of IE, please make sure the dialog first page domain is same with the taskpane domain. 1.如果是Win10和最新版本的IE,请确保对话框的第一页域与任务窗口域相同。 Or you can use other browser to try it. 或者您可以使用其他浏览器进行尝试。 2. If it is Win7&8&8.1 and IE, then you can just try in other browser to see whether the messageParent api is work. 2.如果是Win7&8&8.1和IE,那么您可以尝试在其他浏览器中查看messageParent api是否有效。 We have already done a code change to fix the IE issue. 我们已经完成了代码更改以修复IE问题。 It will be deployed to prod soon. 它将很快部署。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM