Search code examples
ms-officeoffice-js

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


Solution

  • 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