我想在调用 Office.context.ui.displayDialogAsync() 方法时跳过显示消息

I want to skip showing the message when calling Office.context.ui.displayDialogAsync() method

我正在编写 Outlook 加载项。

我想使用 displayDialogAsync() 来显示对话消息。

但是当我使用该方法时,在显示对话框之前会显示确认消息(我附上了屏幕截图)。

是否有跳过此消息的解决方案?

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

・参考

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);
    }

该消息对于防止弹出窗口拦截器是必要的。所以不,如果您使用弹出模式,则无法跳过它。但是,如果您的页面支持 iframing,您可以传递 displayAsIframe=true 参数(参见 documentation);此模式不显示额外确认,因为它显示为带有 Iframe 的浮动 div(与新的 window 相对)。

重要提示:我看到您在 Office Online 中使用 API。请注意,我们尚未正式更新我们的文档和示例以声明它受支持,因此您可能会在此过程中遇到一些问题。我预计一切都会在明年初就位。

在 Outlook Web Access 中,使用 window.open() 而不是对话框 API。这将允许您在不显示此对话框的情况下启动子 window。不过有一些注意事项:

  1. 正在启动的 window 的 URL 必须与您的加载项属于同一域。否则,您可能会看到弹出窗口被阻止的警告。

  2. 如果 window.open() 未作为用户操作的直接结果调用,Firefox 将显示弹出窗口被阻止的警告。如果您的加载项的用户可能正在使用 Firefox,请确保在启动新的 window 时,您是直接在 onClick 处理程序或其他东西中执行它,而不是通过 Promise 或异步回调。

在 Outlook 桌面应用程序中,对话框 API 按预期工作,事实上,使用 window.open() 将始终触发弹出窗口被阻止的警告。

我们的加载项具有类似于以下的逻辑:

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

希望对您有所帮助!