我正在尝试使用Dialog API Office 插件的。
我可以通过以下方式从任务 Pane 成功打开对话框:
$scope.openDialog = function () {
Office.context.ui.displayDialogAsync('https://localhost:3000/home',
function (asyncResult) {
dialog = asyncResult.value;
dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
});
}
我的对话框是 mean-stack
地点。我已添加<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script>
在 index.html
。我尝试使用 Office.context.ui.messageParent(true);
,它在控制台中显示错误:
我在文档中看到我不太理解:
The Office JavaScript library is loaded in the page. (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.initialize = function () { };
在index.html
,错误仍然存在,并且 processMessage
任务 Pane 的似乎没有收到任何内容。
那么我应该对我的 mean-stack
做些什么特别的事情吗?网站,以便它可以使用 messagePerent
?
最佳答案
控制台错误不会给对话框带来任何不良影响。我们已经在内部修复了它。你可以忽略这个错误。您是否检查过 office.context.ui.messageParent 是否为 null 或 undefined ?如果不是,则对话框已成功初始化。那么就只是postMessage方法有问题,你使用的是什么系统和浏览器版本? 1. 如果是Win10和最新版本的IE,请确保对话框首页域名与任务 Pane 域名相同。或者您可以使用其他浏览器尝试一下。 2. 如果是Win7&8&8.1和IE,那么您可以在其他浏览器中尝试一下messageParent api是否有效。我们已经完成了代码更改来修复 IE 问题。它将很快部署到产品中。
关于javascript - 将消息从对话框(平均堆栈站点)发送到任务 Pane ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44183328/