KangoBrowserTab

Summary

Name Description
getId Returns tab unique identifier
getUrl Returns URL for the tab
getTitle Returns title for the tab
isActive Returns true if the window is in focus now
navigate Navigates current tab to new URL
dispatchMessage Dispatches a messages to the content script(s) in the tab
close Closes tab

Methods

getId

KangoBrowserTab.getId()

Returns tab unique identifier.

Returns:tab unique identifier
Return type:string

Example:

// output ID for current active tab
kango.browser.tabs.getCurrent(function(tab) {
    // tab is KangoBrowserTab object
    kango.console.log(tab.getId());
});

getUrl

KangoBrowserTab.getUrl()

Returns URL for tab.

Returns:tab URL
Return type:string

Example:

// output URL for current active tab
kango.browser.tabs.getCurrent(function(tab) {
    // tab is KangoBrowserTab object
    kango.console.log(tab.getUrl());
});

getTitle

KangoBrowserTab.getTitle()

Returns title for tab.

Returns:tab title
Return type:string

Example:

// output title for current active tab
kango.browser.tabs.getCurrent(function(tab) {
    // tab is KangoBrowserTab object
    kango.console.log(tab.getTitle());
});

isActive

KangoBrowserTab.isActive()

Returns true for active tab and false for not active.

Returns:true for active tab and false for not active
Return type:boolean

Example:

kango.browser.tabs.getCurrent(function(tab) {
    // tab is KangoBrowserTab object
    kango.console.log('Current tab is active: ' + tab.isActive());
});

dispatchMessage

KangoBrowserTab.dispatchMessage(string name, variant data)

Dispatches a message to the content script(s) executing in the tab.

See Messaging API section for more details.

Arguments:
  • name (string) – message name
  • data (variant) – JSON serializable data to send

Example:

// This will send a message to current tab content scripts
// In this sample message named 'action' will have two fields data object
// It is possible to use any JSON serializable object
kango.browser.tabs.getCurrent(function(tab) {
    // tab is KangoBrowserTab object
    tab.dispatchMessage('action', {name: 'DoABarrelRoll', count: 5});
});

close

KangoBrowserTab.close()

Closes tab.

Example:

kango.browser.tabs.getCurrent(function(tab) {
    tab.close();
});