2017-08-05 32 views
0

我有一个平均堆栈网站。我想用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。控制台中没有错误。

有没有人知道这里有什么问题?

回答

1

您在调用来自displayDialogAsync的外部URI。这不被支持,并试图这样做会导致一些意想不到的行为。

documentation关于startAddress绝:

初始页面必须在同一个域中父页面。初始页面加载后,您可以转到其他域。

+0

我写谷歌为例。最初它是我的域名上的帮助页面。我稍后会纠正它。 – SoftTimur

+0

无论页面是否在我的域名上,都存在问题... – SoftTimur

+0

页面是否在重定向之前处理office.initialize? –

相关问题