javascript - 将消息从对话框(平均堆栈站点)发送到任务 Pane

标签 javascript angularjs ms-office mean-stack office-js

我正在尝试使用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); ,它在控制台中显示错误:enter image description here

我在文档中看到我不太理解:

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/

相关文章:

javascript - 滚动时如何重叠html正文中的部分?

javascript - 使用单选按钮重复 ng 时出现错误

javascript - 如何防止每次访问路由/页面时在 Controller 中调用 REST API

excel - 基于 64 位构建时为 "Provider cannot be found. It may not be properly installed"

c# - 如何查看是否安装了office

Javascript/CSS 不适用于 IE 10 但适用于 IE 8

java - 在 session 到期时关闭弹出窗口

html - 没有 HTML 元素的 ng-repeat(这次真的没有)

c++ - 在代码内部、if 语句中使用#import

javascript - Firefox Addon 添加了一个 div/iframe 但无法设置 innerHTML/src