Office.js API的displayDialogAsync方法无法打开页面 [英] displayDialogAsync method of Office.js API not opening the page

查看:162
本文介绍了Office.js API的displayDialogAsync方法无法打开页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了这个 displayDialogAsync(…) 在这里工作?我正在使用Office 2016 desktop version:

I used this Microsoft tutorial to build a WORD add-in in VS2017. The add-in works as expected. Then, for a test, I dded a button btnTest in Home.html file's task pane markup. The btnTest calls the following function in Home.js. When you click the btnTest button in task pane the first line of the code (now commented out) opens the specified url in a browser but the second line does nothing. How can I make displayDialogAsync(…) work here? I'm using Office 2016 desktop version:

function MyTestMethod() {

     //window.open('http://localhost:50900/home.html');
     Office.context.ui.displayDialogAsync('http://localhost:50900/home.html');
}

推荐答案

常规疑难解答建议: 请将回调参数添加到displayDialogAsync的调用中. AsyncResult对象传递给回调.在回调的主体中,读取AsyncResult.status和AsyncResult.error属性,并将它们记录到控制台.这将告诉您出了什么问题.

General troubleshooting advice: Please add a callback parameter to the call of displayDialogAsync. An AsyncResult object is passed to the callback. In the body of the callback read the AsyncResult.status and AsyncResult.error properties and log them to the console. This will tell you what's going wrong.

在这种情况下,您正在使用http协议.您链接到的帮助主题说必须使用https.

In this case, you are using the http protocol. The help topic that you linked to says that https is required.

我强烈建议每个人在使用Dialog API之前通读这篇文章:

I strongly recommend that everyone read through this article before working with the Dialog API: Dialog API in Office Add-ins.

这篇关于Office.js API的displayDialogAsync方法无法打开页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆