使用 Office Online 对话框 API 设置对话框的恒定大小

2024-02-29

有没有办法为使用打开的对话框设置恒定大小对话框API https://dev.office.com/docs/add-ins/develop/dialog-api-in-office-add-ins,通过使用 min-width/max-width CSS 属性还是其他方式?该 API 只允许设置宽度和高度百分比,这使得在调整大小或使用不同分辨率时框看起来不一致(1024px 的 30% 是一个瘦窗口,但例如 1920 看起来不错)。

我注意到“Office 加载项”商店弹出窗口似乎有一个最小宽度/最大宽度,因此在调整大小时它可以保持一致的外观,我希望我也可以利用它的功能。


干得好:

var dim = pixelToPercentage(700, 350);
Office.context.ui.displayDialogAsync(window.location.origin + "/pop-ups/create_export_link.html",
                { height: dim.height, width: dim.width },
                createExportLinkCallback);

支撑函数为:

function pixelToPercentage(heightInPixel, widthInPixel) {
    var height = Math.floor(100 * heightInPixel / screen.height);
    var width = Math.floor(100 * widthInPixel / screen.width);
    return { height: height, width: width };
}

这样您就可以动态计算百分比格式的尺寸。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 Office Online 对话框 API 设置对话框的恒定大小 的相关文章

随机推荐