Outlook 客户端加载项:链接和 JS 重定向到其他域,打开一个新的浏览器选项卡

Outlook client add-ins: links and JS redirects to other domain, open a new browser tab

我的站点是 domaina.com。当我在 Microsoft Edge DevTools Preview 上执行此代码时:

location.href = domainb.com/xxx/xxx

它无法重定向到右侧站点附加面板上的 domainb.com,它会打开我的默认浏览器来加载我的链接。

我已将 domainb.com 添加到我的清单中,如下所示:

<AppDomain>https://domainb.com</AppDomain>

当我执行如下代码时:

var displayUrl = "https://domainb.com";
Office.context.ui.displayDialogAsync(displayUrl, { height: 75, width: 40 }, function(result) {
    console.log('displayDialogAsync: ');
    console.log(result);
});

Edge DevTools 将控制台记录如下错误结果:

[object Object]: {error: Object, status: "failed", value: undefined}

error: Object
code: 12004
message: "The domain of the URL is not included in the AppDomains element in the manifest, and is not subdomain of source location."
name: "Display Dialog Error"

__proto__: Object
status: "failed"
value: undefined

__proto__: Object

但事实上, 我已将 domainb.com 添加到我的清单中:

<AppDomains>
<AppDomain>https://domainb.com</AppDomain>
<AppDomains>

但是对

没用
Window 10 1903 Verison OS build: 18362.535
Outlook client: Verison 1911 (Build 12228.20364 Click-to-Run) MSO (16.0.12228.20322) 64Bit.

我认为这是由 Edge 引擎引起的。 https://docs.microsoft.com/en-us/office/dev/add-ins/concepts/browsers-used-by-office-web-add-ins

更多详情:https://github.com/OfficeDev/office-js/issues/917

IIRC 当您使用 displayDialogAsync 打开对话框时,您传递的 url 必须在本地主机上(例如 https://localhost:3000/dialog.html),从那里您可以重定向到您拥有的任何站点添加到 <AppDomains>

<!-- dialog.html -->
...
<script>
Office.initialize = () => {
  window.location.href = 'https://url_included_in_app_domains' // domainb.com/xxx/xxx
}
...
</script>