【问题标题】:How do I display a message similar to Window.alert() in OfficeJS如何在 OfficeJS 中显示类似于 Window.alert() 的消息
【发布时间】:2019-06-09 10:12:36
【问题描述】:

我正在尝试显示自定义消息,但 window.alert() 在 OfficeJS 中受到限制。

我找到了一个建议使用app.showNotification(title, message);的解决方案

Office.initialize = function (reason) {
        $(document).ready(function () {
             app.showNotification("Title For the Notification", "test");
    });
 });

浏览器抛出

“应用程序未定义错误”。

我缺少哪个模块?

【问题讨论】:

  • 您从 Office Add-in Dialog API Example 的上下文中获取 3 行代码,它使用 FabricUI 包来显示警报样式对话框(基本上是当前页面上的图层)。底线:app 是某人在您未复制的代码中定义的应用程序; showNotification 是某人实现的自定义功能。与 OfficeJS 无关。
  • 我明白了,感谢您指出这一点。我现在很清楚了!

标签: javascript outlook outlook-addin office-js outlook-web-app


【解决方案1】:

要回答原始问题(在您的标题中),您可以使用 Fabric-UI Dialog API 来实现此功能。可用对话框样式的选项示例over here。您也可以使用任何其他 UI 包...... JQuery UI、JQuery Mobile 等。

【讨论】:

  • 我将尝试使用 JQuery UI,因为我试图完全避免 Dialog API
【解决方案2】:

除了按照 Slava 的建议使用 Fabric 对话框之外,您还可以在 Office.js 中使用 Dialog API。这里有一个讨论:Use the Dialog API in your Office Add-ins

【讨论】:

  • 我忘了提到我目前正在使用我完全不喜欢的 Dialog API,因为它确实会在 Outlook Windows 上生成错误。我想不惜一切代价避免它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-05
  • 2011-03-25
相关资源
最近更新 更多