在对话框api中重定向到另一个对话框

在对话框api中重定向到另一个对话框

本文介绍了在对话框api中重定向到另一个对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用office api在对话框api中重定向另一个对话框

Is it possible to redirect another dialog within a dialog api using office api

问候

vani

vani

推荐答案

只能从主机窗口打开一个对话框。但Dialog API不提供任何方法来重定向到另一个对话框或页面。因此,为了重定向到另一个对话框,我们需要关闭然后显示一个新对话框。

Only one dialog box can be open from a host window. But Dialog API doesn't provide any method to redirect to another dialog or page. So to redirect to another dialog, we need to close and then show a new one.

例如,创建一个按钮openNewDialog,使用UI.messageParent方法传递消息"openNewDialog""  到其父/开启页面

For example, create a button openNewDialog, use UI.messageParent method to deliver a message "openNewDialog" to its parent/opener page

        function openNewDialog() {
            Office.context.ui.messageParent("openNewDialog");
        }

在第一个对话框的回调中添加一个DialogMessageReceived 事件处理程序,以检查已发送的消息。

Add a DialogMessageReceived event handler in the callback of the first dialog to check delivered message.

function dialogCallback(asyncResult) {
    if (asyncResult.status == "failed") {
        // ..
    }
    else {
        dialog = asyncResult.value;
        /*Messages are sent by developers programatically from the dialog using office.context.ui.messageParent(...)*/
        dialog.addEventHandler(Office.EventType.DialogMessageReceived, messageHandler);

    }
}
function messageHandler(arg) {
    switch (arg.message) {
        case "openNewDialog":
            dialog.close();
            Office.context.ui.displayDialogAsync(window.location.origin + "/NewDialog.html", { height: 50, width: 50 }, dialogCallback);
            break;
        default:
            dialog.close();
            showNotification(arg.message);
            break;
    }
}

您可以从
https://1drv.ms/u/s!AkcxDWH1nFmJpS8bAAIon_DVSli
-

You could download a sample project from https://1drv.ms/u/s!AkcxDWH1nFmJpS8bAAIon_DVSli-

问候,

Celeste


这篇关于在对话框api中重定向到另一个对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 02:03