【发布时间】:2016-01-28 22:41:36
【问题描述】:
我正在努力检查我的托管 Web 应用程序是由浏览器打开还是在 Outlook 2013/2016 客户端中打开。
这是我的方法:
/**
* Check if the app is running in outlook
*/
$rootScope.isOutlook = false;
$(document).ready(function () {
try {
Office.initialize = function() {
var hostType = Office.context.mailbox.diagnostics.hostName;
if (hostType === "Outlook" || hostType === "Mac Outlook" || hostType === "OutlookWebApp") {
$rootScope.isOutlook = true;
}
};
} catch (e) {
if (e instanceof TypeError) {
// catch error if web app is opened in browser.
console.log('Not in office context! Generated error: ' + e);
}
}
});
$log.debug('isOutlook: ' + $rootScope.isOutlook);
函数本身就像一个魅力,但我无法摆脱“未捕获的类型错误”。 它一直在我的浏览器控制台中向我抛出这个 Uncaught TypeError:
Uncaught TypeError: window.external.GetContext is not a function
【问题讨论】:
标签: javascript office365 office365-apps office-js