我有一个卑鄙的堆栈网站。我想使用ExecuteFunction绑定按钮以在对话框中启动此网站。这是我的FunctionFile.html
:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<title></title>
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js" type="text/javascript"></script>
<script>
var clickEvent;
(function () {
Office.initialize = function (reason) {
};
})();
function showNotification(text)
{
writeToDoc(text);
clickEvent.completed();
}
function doSomethingAndShowDialog(event) {
clickEvent = event;
Office.context.ui.displayDialogAsync("https://www.google.com", {}, function () {})
}
function writeToDoc(text)
{
Office.context.document.setSelectedDataAsync(text,
function (asyncResult) {
var error = asyncResult.error;
if (asyncResult.status === "failed") {
console.log("Unable to write to the document: " + asyncResult.error.message);
}
});
}
</script>
</head>
<body>
Function file body is never displayed.
</body>
</html>
在manifest.xml
我使用:
<FunctionFile resid="Contoso.DesktopFunctionFile.Url" />
... ...
<bt:Url id="Contoso.DesktopFunctionFile.Url" DefaultValue="https://localhost:3000/htmls/FunctionFile.html" />
我意识到在加载清单后,我们可以通过单击按钮启动对话框。但是,在手动关闭对话框并再次单击该按钮后,我们需要等待几分钟才能看到通知窗口... wants to display a new window
。控制台中没有错误。
有谁知道这里有什么问题?
答案 0 :(得分:2)
您正在从startAddress
调用外部URI。这不受支持,并且尝试这样做会导致许多意外行为。
documentation关于{{1}}必须:
初始页面必须与父页面位于同一个域中。加载初始页面后,您可以转到其他域。