I have an Office Add-In written in the new JavaScript API, inside of it, I have a JS function which after some logic opens a web app in a new window using window.open(url, '_blank')
It works when called from the add-in pane in Outlook Web in both, localhost
hosted add-in, as well as after deployment on heroku.
However when called from a command (add-in button on ribbon) it works only when the add-in is hosted on localhost, after I deploy it on heroku, the add-in works, shows commands in the ribbon, performs the JS logic, but window.open
does nothing.
Looks like the only way to open a new window is by using Office.context.ui.displayDialogAsync
but even then it works only if the page is on the same origin as the add-in code.
I would think that there are some security restrictions, but why then it worked when hosted on localhost? Is there any way, to open a browser window from a command in Outlook using the new Javascript API?
My experience with this has been that
window.open
is not consistently reliable across the different platforms, which sort of forces you to useOffice.context.ui.displayDialogAsync
. As you mentioned, it fusses at you if you try to open a page that's not on your domain. I've found there's a couple of ways around this that might be viable depending on your usage scenario:<AppDomains>
section of your manifest to include the site you want to open up the window to. This section acts as a sort of white list.I think
window.location.href
will work for you.