Konstantin Kreft
Konstantin Kreft

Reputation: 623

Detect if web application is opened in outlook-add-in

I'm struggeling to check if my hosted web application is opened by a browser or in the Outlook 2013/2016 client.

I have one web application, which must provide different features for users in a browser and in the Outlook 2013/2016 sandboxed iframe.

My approach

with AngularJS in the mainController:

$rootScope.isIFrame = false;
if (window.location !== window.parent.location) {
  // The page is in an iframe
  $rootScope.isIFrame = true;
};
$log.debug('isIFrame: ' + $rootScope.isIFrame);

Upvotes: 2

Views: 1011

Answers (1)

lgaud
lgaud

Reputation: 2479

Check out Office.context.mailbox.diagnostics.hostName:

Gets a string that represents the name of the host application. A string that can be one of the following values: Outlook, Mac Outlook or OutlookWebApp.

Upvotes: 1

Related Questions