外部链接的 Office 加载项清单中不需要 AppDomains?

AppDomains not needed in Office add-in manifest for external links?

我创建了一个简单的 Office 加载项,其中的清单没有 <AppDomains> 部分。然后,我将以下 link 添加到加载项 .html 文件中:

<a href="https://www.tutorialrepublic.com">Test</a>

当我在 Office Online 或桌面 MS Word 中加载加载项并单击 link 时,加载项框架从 www.tutorialrepublic.com 加载 html。

根据此处的描述,我预计这会被阻止:https://docs.microsoft.com/en-us/office/dev/add-ins/develop/add-in-manifests?tabs=tabid-1#specify-domains-you-want-to-open-in-the-add-in-window

任何人都可以解释差异吗?我发现我也可以提交表单并将 window.location.href 设置为外部域,它们在插件 iframe 中打开,而不是像预期的那样在单独的 window 中打开。

OP 链接到的文档有误。它已被纠正。相关段落现在说:

When running in Office Online, your task pane can be navigated to any URL. However, in desktop platforms, if your add-in tries to go to a URL in a domain other than the domain that hosts the start page (as specified in the SourceLocation element of the manifest file), that URL opens in a new browser window outside the add-in pane of the Office host application.

To override this (desktop Office) behavior, specify each domain you want to open in the add-in window in the list of domains specified in the AppDomains element of the manifest file. If the add-in tries to go to a URL in a domain that is in the list, then it opens in the task pane in both desktop Office and Office Online. If it tries to go to a URL that isn't in the list, then, in desktop Office, that URL opens in a new browser window (outside the add-in pane).

Note

This behavior applies only to the root pane of the add-in. If there is an iframe embedded in the add-in page, the iframe can be directed to any URL regardless of whether it is listed in AppDomains, even in desktop Office.