TabContext
TabContext provides the ability to listen to tab-level events such as ContextOpen, ContextClose and perform tab-level operations such as FocusTab and CloseTab.
Supported events are as follows:
Event Name | Description |
---|---|
ContextOpen | This event is initiated when a new object gets opened in a particular tab. |
ContextClose | This event is initiated when an object gets closed in a particular tab. |
Here are the supported actions:
Action Name | Description |
---|---|
FocusTab | This action is used to focus on a particular browser or MSI tab. |
CloseTab | This action is used to close a particular browser or MSI tab. |
To get the reference of TabContext, you can use the getTabContext function. This function provides a reference to the active tab in which the application is loaded. In addition, it can pass the browserTabId as an optional parameter to get a particular browser tab's context.
Here's the syntax:
getTabContext(browserTabId?: string): Promise<ITabContext>;
Here's the parameters:
Parameter Name | Required? | Description |
---|---|---|
browserTabId | No | A particular browser tab's id. Note:
You can get each browser's tabId by calling the getCurrentTabId API on frameworkProvider from each browser tab. |
The following code sample shows an example in TypeScript:
/// <reference path="uiEventsFramework.d.ts"/>
const frameworkProvider : IUiEventsFrameworkProvider = await
CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID');
const tabContext: ITabContext = await frameworkProvider.getTabContext();
The following code sample shows an example in JavaScript:
const frameworkProvider = await
CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID');
const tabContext = await frameworkProvider.getTabContext();