Office.js API 的 displayDialogAsync 方法未打开页面
displayDialogAsync method of Office.js API not opening the page
我用过这个 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(…) 在这里工作?我正在使用 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 属性并将它们记录到控制台。这会告诉你出了什么问题。
在本例中,您使用的是 http 协议。您链接到的帮助主题说需要 https。
我强烈建议大家在使用对话框之前通读这篇文章API:Dialog API in Office Add-ins。
我用过这个 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(…) 在这里工作?我正在使用 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 属性并将它们记录到控制台。这会告诉你出了什么问题。
在本例中,您使用的是 http 协议。您链接到的帮助主题说需要 https。
我强烈建议大家在使用对话框之前通读这篇文章API:Dialog API in Office Add-ins。