简体   繁体   中英

How do I display a message similar to Window.alert() in OfficeJS

I'm trying to display a custom message, but window.alert() is restricted in OfficeJS.

I have found a solution which suggests using app.showNotification(title, message);

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

Browser throws

"app is undefined error".

Which module am I missing ?

To answer on original question (in your title) you may use Fabric-UI Dialog API to achive this functionality. The examples of the options for available dialog's styles over here . You may use any other UI package as well ... JQuery UI, JQuery Mobile, etc.

In addition to using the Fabric dialog as Slava suggested, you can also use the Dialog API in Office.js. There's a discussion of it here: Use the Dialog API in your Office Add-ins .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM