3
votes

I'm coding an Outlook Add-in.

I want to show a dialog message by using displayDialogAsync().

But when I use the method, the confirmation message is shown, before displaying a dialog (I attached a screenshot).

Are there any solutions for skipping this message?

screen shot : the message when a code calls displayDialogAsync()

・reference

https://dev.office.com/docs/add-ins/develop/dialog-api-in-office-add-ins

    function openWindow()
    {
        var startAddress = 'https://localhost:44303/AppCompose/Sample/Sample.html';
        Office.context.ui.displayDialogAsync(startAddress);
    }
2
Thank you for your editing.Ichiro

2 Answers

4
votes

The message is necessary to prevent pop-up blockers. So no, there is no way to skip it if you use pop-up mode. However, if your page supports iframing you can pass the displayAsIframe=true parameter (see documentation); this mode doesn't show the extra confirmation because it is displayed as a floating div with an Iframe (as opposed to a new window).

Important: I see you are using the API in Office Online. Please be aware that we have not yet officially updated our documentation and samples to state that it's supported so you might see some bumps along the way. I expect everything will be in place by early next year.

1
votes

In Outlook Web Access, use window.open() instead of the Dialog API. This will allow you to launch a child window without displaying this dialog. There are some caveats, though:

  1. The URL of the window being launched must belong to the same domain as your add-in. Otherwise, you may see a popup blocked warning.

  2. Firefox will show a popup blocked warning if window.open() is not called as a direct result of a user action. If your add-in's users may be using Firefox, just make sure that when launching a new window, that you're doing it directly within an onClick handler or something, not via a Promise or an async callback.

In Outlook desktop apps, the Dialog API works as expected, and in fact, using window.open() will always trigger a popup blocked warning.

Our add-in has logic similar to the following:

function launchDialog(url) {
  if (/WebApp/.test(Office.context.mailbox.diagnostics.hostName)) {
    window.open(url);
  } else {
    Office.context.ui.displayDialogAsync(url);
  }
}

Hope this helps!