You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何取消Office Online调用displayDialogAsync时的新窗口权限提示?

Ah, I’ve dealt with this exact permission prompt headache in Office Online before—total buzzkill for user experience! The good news is there’s a reliable way to make that "wants to display a new window" notification disappear entirely. Let’s break down the steps:

Fixing the Office Online Dialog Permission Prompt

First, quick context: that prompt pops up because Office Online is wary of untrusted domains trying to open new windows. To bypass it, we need to tell Office our dialog is trusted and render it inline instead of as a separate window.

  • Whitelist your dialog’s domain in the add-in manifest
    Before anything else, make sure the domain hosting your dialog page is added to the AppDomains section of your Office Add-in manifest. This is Office’s way of verifying the dialog source is safe. For example:

    <AppDomains>
      <AppDomain>https://your-addin-domain.com</AppDomain>
    </AppDomains>
    

    Double-check the domain matches exactly (no extra slashes, correct HTTPS protocol—Office requires HTTPS for all add-in content).

  • Enable inline rendering with displayInIframe
    The magic setting here is displayInIframe in your displayDialogAsync options. When set to true, Office Online renders the dialog inside an iframe within the current Office window instead of trying to spawn a new browser window—this skips the permission request entirely. Here’s how to implement it:

    function openCustomDialog() {
      const dialogSettings = {
        displayInIframe: true,
        width: 65, // Width as percentage of the parent window
        height: 55,
        title: "Your Dialog Title" // Replace with your desired title
      };
    
      Office.context.ui.displayDialogAsync(
        "https://your-addin-domain.com/your-dialog-page.html",
        dialogSettings,
        (asyncResult) => {
          if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
            const dialog = asyncResult.value;
            // Optional: Set up event handlers for dialog interactions
            dialog.addEventHandler(Office.EventType.DialogClosed, onDialogClosed);
          } else {
            console.error("Failed to open dialog: ", asyncResult.error.message);
          }
        }
      );
    }
    
  • Key things to remember

    • displayInIframe only works in Office Online (web clients). Desktop Office apps ignore this setting, but they don’t show that permission prompt anyway—they use native system dialogs by default.
    • Your dialog page must be served over HTTPS (non-negotiable for Office Online add-ins).
    • If the prompt still appears, double-check your AppDomains entry—even a tiny typo can break the trust relationship.

内容的提问来源于stack exchange,提问作者Daniel A. White

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:26:04