Office.js对话框在显示后立即关闭(Excel Online)

时间:2018-04-03 21:20:57

标签: office-js

我正在实现Excel加载项的对话框。一切都适用于桌面版。但是在Office Online上托管时,对话框会在显示后立即关闭。

当我从对话框页面中删除Office.initialize分配时 - 它正确显示。但只是添加此脚本会导致对话框关闭。

<script type="text/javascript">
    // The initialize function must be run each time a new page is loaded
    Office.initialize = function (reason) {
    };
</script>

只有在使用displayInIframe:true时,错误仍然存​​在。

使用了整个对话框标记:

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Office JavaScript API -->
    <script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js"></script>
    <!-- Template styles -->
    <link href="/css/app.css" rel="stylesheet" type="text/css" />
</head>

<body class="ms-font-m">
    <div class="page dialog-external">
    </div>
    <div class="k-loading-mask">
        <div class="k-loading-color"></div>
        <div class="k-loading-image"></div>
    </div>
    <script type="text/javascript">
        // The initialize function must be run each time a new page is loaded
        Office.initialize = function (reason) {
        };
    </script>
</body>
</html>

致电代码:

Office.context.ui.displayDialogAsync(window.location.origin + "/dialog.html?v=1.0.0.0&" + common.getQueryString(options), {
        width: 40,
        height: 50,
        displayInIframe: true
    }, function (asyncResult) {
        if (asyncResult.status == "failed") {
            showInternalDialog(options);
        }
        dialog = asyncResult.value;
        dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
    });

1 个答案:

答案 0 :(得分:0)

Microsoft Office产品团队已转载此内容。这是我们正在研究的新bug。与此同时,解决方法是不将displayInIframe设置为true

更新:正如Michael Z在评论中指出的那样。该错误已得到修复。谢谢你的耐心等待。