kango.browser.tabs

Summary

Name Description
getAll Retrieves all tabs
getCurrent Retrieves current active tab
create Creates new tab

Methods

getAll

kango.browser.tabs.getAll(callback)

Function will prepare an array of all the tabs available and pass it to callback specified.

Arguments:
  • callback (function(tabs)) – callback function. tabs is an Array of KangoBrowserTab objects

Example:

// enumerate all the browser tabs and log their urls to console
kango.browser.tabs.getAll(function(tabs) {
        // tabs is Array of KangoBrowserTab
        for(var i = 0; i < tabs.length; i++){
                kango.console.log(tabs[i].getUrl());
        }
});

getCurrent

kango.browser.tabs.getCurrent(callback)

Retrieves currently active tab and pass KangoBrowserTab object for it to callback as argument.

Arguments:
  • callback (function(tab)) – callback function. tab is a KangoBrowserTab object

Example:

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

create

kango.browser.tabs.create(details)

Creates new tab with specified parameters.

Arguments:
  • details – create parameters

Details object:

details = {
        string url,     // URL of the tab to open
        boolean focused // Tab will be active or not. Default is true.
}

Example:

// open URL in new tab
kango.browser.tabs.create({url:'http://example.com/'});