displayDialogAsync method of Office.js API not opening the page

家住魔仙堡 提交于 2019-12-24 10:19:05

问题


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');
}

回答1:


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.

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

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



来源:https://stackoverflow.com/questions/52937467/displaydialogasync-method-of-office-js-api-not-opening-the-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!