17

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.

Daniel Phan
  • 227
  • 2
  • 8
  • 1
    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 Aug 10 '17 at 20:52
  • 1
    @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. tags) might not? – Daniel Phan Aug 11 '17 at 23:11
  • 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 Aug 15 '17 at 21:14
  • @Carbo any update on this? Just wondering if there's anything my add-in can do to prevent this from happening. – Daniel Phan Aug 28 '17 at 23:47
  • Hi Daniel, you should check to see if dialog API exists. If it exists, you can use it knowing it will work fine. If it doesn't exist, use window.open - that version of Outlook will not launch default browser (default browser support was added much after we added support for display dialog). – Outlook Add-ins Team - MSFT Sep 08 '17 at 21:11
  • Thanks, I'll try this. Just a note: when I tested the dialog API with Outlook 2013, I saw that the add-in window had access to the dialog API, but the child window did not (it had a different requirement set from its parent), so it could not communicate back to the add-in. I can probably work around this by checking the version of Outlook (instead of checking the requirement set), but just FYI. – Daniel Phan Sep 08 '17 at 22:15
  • 1
    The Dialog cannot make API calls using Office.js. It is only capable of using the [Office.context.ui.messageParent](https://dev.office.com/docs/add-ins/develop/dialog-api-in-office-add-ins#sending-information-from-the-dialog-box-to-the-host-page) API. The parent can use those messages to leverage the Office.js APIs in the parent. – Outlook Add-ins Team - MSFT Sep 08 '17 at 22:29
  • Thanks, this worked! I think the last time I tried integrating the dialog API, I forgot to wait for Office.initialize inside the popup window (so none of the methods were available). – Daniel Phan Sep 19 '17 at 03:20

2 Answers2

2

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.

robinCTS
  • 5,746
  • 14
  • 30
  • 37
0

As 2022 docs were updated.

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

abestrad
  • 898
  • 2
  • 12
  • 23