2017-08-05 31 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? –

相關問題