2016-03-14 64 views
0

我有一个Outlook插件的JavaScript API,并从我的网站,我想重定向到正确的环境的应用程序,如何检测Office 365中的环境?

var isSetSupported = function(Application, version) { 
       return window["Office"] && Office.context.requirements && Office.context.requirements.isSetSupported(Application + 'Api', version); 
      }; 

      //heck to return the powerpoint library because isSetSupported returns false for PowerpointApi 1.0| 1.1| 1.2 returns false 
      var isPowerpointEnviroment = function() { 
       return window.location.search.indexOf('_host_Info=Powerpoint') != -1; 
      } 

      //heck to return the outlook library because isSetSupported returns false for OutlookApi 1.0| 1.1| 1.2 returns false 
      var isOutlookEnviroment = function() { 
       return window.location.search.indexOf('_host_Info=Outlook') != -1 || (window.external && window.external.GetContext && typeof window.external.GetContext() == 'object'); 
      } 

      if (isSetSupported("Word", 1.1)) { 
       return "wordJs"; 
      } 
      if (isSetSupported("Excel", 1.1)) { 
       return "excelJs"; 
      } 
      if (isOutlookEnviroment()) { 
       return "outlookJs"; 
      } 
      if (isPowerpointEnviroment()) { 
       return "powerpointJs"; 
      } 

      return "webApp"; 

从本地计算机的前景它是这样工作的,但对于office365展望它不起作用。

+0

我们正在评估加入一个API来检测主机(“的Excel,Word,Outlook中等等)和平台(桌面,Mac,Web等)信息为了确保我们正在考虑它,你介绍一下你正在面对的特定用例,这导致你寻求这个API吗?谢谢! –

回答