【问题标题】:Outlook client add-ins: links and JS redirects to other domain, open a new browser tabOutlook 客户端加载项:链接和 JS 重定向到其他域,打开新的浏览器选项卡
【发布时间】:2020-01-19 17:27:24
【问题描述】:

我的网站是 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

【问题讨论】:

    标签: office-js appdomain outlook-web-addins


    【解决方案1】:

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

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

    【讨论】:

    • 嗨lumpenstein,非常感谢您的解决方案。我认为这是我使用 displayDialogAsync 的一种解决方法。但我仍然想在任务面板上使用 window.location.href(没有 displayDialogAsync),它是 manifast.xml 上的 messageReadTaskPaneUrl 标记。它将打开一个新的浏览器选项卡。你对这个案子有什么建议吗?非常感谢!
    • 遗憾的是没有,但我记得曾经读过同样的问题,但找不到链接:/
    • 找到了错误。有关更多详细信息和解决方案,请参阅:github.com/OfficeDev/office-js/issues/917
    • 很高兴您发现了错误 :) TL:DR for others:清单中的 AppDomains 不接受通配符,必须包含协议。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多