Office.DialogOptions interface

提供对话框显示方式的选项。

属性

asyncContext

在传递给回调的 AsyncResult 对象的 asyncContext 属性中返回的、未更改的任何类型的用户定义的项。

displayInIframe

确定是否应在 IFrame 中显示对话框。 此设置仅适用于 Office web 版,其他平台会忽略此设置。 如果 false (默认) ,则对话框将显示为新的浏览器窗口, (弹出) 。 对于无法在 IFrame 中显示的身份验证页建议使用此值。 如果为 true,则对话框将显示为带有 IFrame 的浮动覆盖。 对于用户体验和性能而言,这是最佳选择。

height

以占当前显示器的百分比的形式,定义对话框的高度。 默认值为 80%。 下限为 250px。

promptBeforeOpen

确定是否向用户显示弹出窗口阻止程序对话框。 默认值为 true。

true - 框架显示用于触发导航的弹出窗口,并避开浏览器的弹出窗口阻止程序。 false - 对话框不会显示,开发人员必须处理弹出窗口(通过提供用户界面项目来触发导航)。

width

以占当前显示器的百分比的形式,定义对话框的宽度。 默认值为 80%。 下限为 150px。

属性详细信息

asyncContext

在传递给回调的 AsyncResult 对象的 asyncContext 属性中返回的、未更改的任何类型的用户定义的项。

asyncContext?: any

属性值

any

displayInIframe

确定是否应在 IFrame 中显示对话框。 此设置仅适用于 Office web 版,其他平台会忽略此设置。 如果 false (默认) ,则对话框将显示为新的浏览器窗口, (弹出) 。 对于无法在 IFrame 中显示的身份验证页建议使用此值。 如果为 true,则对话框将显示为带有 IFrame 的浮动覆盖。 对于用户体验和性能而言,这是最佳选择。

displayInIframe?: boolean

属性值

boolean

height

以占当前显示器的百分比的形式,定义对话框的高度。 默认值为 80%。 下限为 250px。

height?: number,

属性值

number

示例

// The following example shows how to open a dialog with a specified size. It also shows
// how to register a function to handle the message when Office.UI.messageParent() is called
// in the dialog and how to use that handler to close the dialog. The implementation of the processMessage() function is omitted.

Office.context.ui.displayDialogAsync("https://www.contoso.com/myDialog.html", { height: 30, width: 20 },
    (asyncResult) => {
        const dialog = asyncResult.value;
        dialog.addEventHandler(Office.EventType.DialogMessageReceived, (arg) => {
            dialog.close();
            processMessage(arg);
        });
    }
);

// The following example does the same thing in TypeScript.

Office.context.ui.displayDialogAsync("https://www.contoso.com/myDialog.html", { height: 30, width: 20 },
    (asyncResult: Office.AsyncResult) => {
        const dialog: Office.Dialog = asyncResult.value;
        dialog.addEventHandler(Office.EventType.DialogMessageReceived, (arg: string) => {
            dialog.close();
            processMessage(arg);
        });
    }
);

promptBeforeOpen

确定是否向用户显示弹出窗口阻止程序对话框。 默认值为 true。

true - 框架显示用于触发导航的弹出窗口,并避开浏览器的弹出窗口阻止程序。 false - 对话框不会显示,开发人员必须处理弹出窗口(通过提供用户界面项目来触发导航)。

promptBeforeOpen?: boolean;

属性值

boolean

width

以占当前显示器的百分比的形式,定义对话框的宽度。 默认值为 80%。 下限为 150px。

width?: number,

属性值

number

示例

// The following example shows how to open a dialog with a specified size. It also shows
// how to register a function to handle the message when Office.UI.messageParent() is called
// in the dialog and how to use that handler to close the dialog. The implementation of the processMessage() function is omitted.

Office.context.ui.displayDialogAsync("https://www.contoso.com/myDialog.html", { height: 30, width: 20 },
    (asyncResult) => {
        const dialog = asyncResult.value;
        dialog.addEventHandler(Office.EventType.DialogMessageReceived, (arg) => {
            dialog.close();
            processMessage(arg);
        });
    }
);

// The following example does the same thing in TypeScript.

Office.context.ui.displayDialogAsync("https://www.contoso.com/myDialog.html", { height: 30, width: 20 },
    (asyncResult: Office.AsyncResult) => {
        const dialog: Office.Dialog = asyncResult.value;
        dialog.addEventHandler(Office.EventType.DialogMessageReceived, (arg: string) => {
            dialog.close();
            processMessage(arg);
        });
    }
);