getEnclosingPrimaryTabId()
Returns the ID of the current primary tab. This
method works within a primary tab or subtab, not within the navigation tab or custom
console components. This method is only available in API version 20.0 or later.
Syntax
sforce.console.getEnclosingPrimaryTabId((optional)callback:function)
Arguments
Name | Type | Description |
---|---|---|
callback | function | JavaScript method that’s called upon completion of the method. |
Sample Code–Visualforce
<apex:page standardController="Case">
<A HREF="#" onClick="testCloseTab();return false">
Click here to close this primary tab</A>
<apex:includeScript value="/support/console/64.0/integration.js"/>
<script type="text/javascript">
function testCloseTab() {
//First find the ID of the current primary tab to close it
sforce.console.getEnclosingPrimaryTabId(closeSubtab);
}
var closeSubtab = function closeSubtab(result) {
//Now that we have the primary tab ID, we can close it
var tabId = result.id;
sforce.console.closeTab(tabId);
};
</script>
</apex:page>