17
votes

I'm seeing an issue with my Outlook Add-in (running in Outlook 2016) where when I open a popup window using window.open, it sometimes opens in the user's default browser (e.g. Chrome) instead of the browser running the add-in (e.g. the IE11 web view embedded in Outlook 2016). This is a problem because it prevents the popup window from communicating with the add-in, which is necessary for clickjacking protection.

Is there a way to force the popup window to be opened in the same browser that is running the add-in, without using the Dialog API? I would like to support requirement set 1.3.

2
I do not know why it is opening in Chrome. The window.open call from Outlook should always open in IE. If you click on a link on your task pane however, that link will open in your default browser. - Carbo
@Carbo that's unfortunate, I was hoping that there would be something that I could do to fix this. Just to confirm, are you saying that window.open calls should always open in IE, but links (i.e. <a> tags) might not? - Daniel Phan
It looks like I was wrong. I am still looking into it, but I was able to get window.open from an add-in task pane to open FireFox from Outlook 2016 by making FireFox the handler for the http and https protocols in Windows 10. Links on the task pane also opened in FireFox. - Carbo
@Carbo any update on this? Just wondering if there's anything my add-in can do to prevent this from happening. - Daniel Phan
The Dialog cannot make API calls using Office.js. It is only capable of using the Office.context.ui.messageParent API. The parent can use those messages to leverage the Office.js APIs in the parent. - Outlook Add-ins Team - MSFT

2 Answers

2
votes

You should check to see if the displayDialogAsync API exists. It was added in requirement set 1.4.

If it exists, we recommend using it. Please note that the dialog can only call the Office.context.ui.messageParent API. This API allows the dialog to communicate one-way with the add-in. The add-in can use those messages to leverage the Office.js APIs.

If the displayDialogAsync API doesn’t exist you can leverage window.open. However, in this case the default browser will not be launched.

0
votes

As 2022 docs were updated.

The API documentation was moved from dev.office.com (these links don't work anymore) to docs.microsoft.com. And here you will find an example on how to use this api.