Open an html page in a default browser from an add-in

大憨熊 提交于 2019-11-28 01:45:43

问题


I would like to insert a hyperlink to the task pane of my add-in, and I want this link to open support.html page in a default browser.

<a href="https://example.com/support.html" target="_blank">Support</a>

However, the above code opens support.html page inside the task pane. Users may not know how to go back to the main page of the add-in.

Does anyone know how to open the page in a default browser of users? (By the way, is it recommended to launch something outside the add-in? If not, what's the common UX design for the help page?)


回答1:


You can open a new browser window from an Office Add-in via JavaScript: simply

window.open("your-url.com");

Alternatively, if you want the browsing experience to be more in-line, you can use the dialog API:

Office.context.ui.displayDialogAsync(url,
    { height: 75, width: 80, requireHTTPS: true });

See https://github.com/OfficeDev/Office-Add-in-UX-Design-Patterns-Code/tree/master/templates/feedback/office-store for a full example.

~ Michael Zlatkovsky, Developer on Office Extensibility Team, MSFT



来源:https://stackoverflow.com/questions/38044279/open-an-html-page-in-a-default-browser-from-an-add-in

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