Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?)

like image 287
SoftTimur Avatar asked Jun 26 '16 23:06

SoftTimur


2 Answers

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

like image 126
Michael Zlatkovsky - Microsoft Avatar answered Sep 20 '22 18:09

Michael Zlatkovsky - Microsoft


If you are trying to open the default OS Browser use the following:

Office.context.ui.openBrowserWindow('https://someurl.com')

This launches the default browser instead of a Dialog box attached to the Addin

https://docs.microsoft.com/en-us/javascript/api/office/office.ui?view=excel-js-preview#openBrowserWindow_url_

like image 22
Phil C Avatar answered Sep 17 '22 18:09

Phil C