KangoBrowserWindow

Summary

Name Description
getId Returns window unique identifier
getTabs Retrieves all tabs in window
getCurrentTab Retrieves current active tab in window
isActive Returns true if the window is in focus now

Methods

getId

KangoBrowserWindow.getId()

Returns window unique identifier.

Returns:window unique identifier
Return type:string

Example:

kango.browser.windows.getCurrent(function(win) {
    // win is KangoBrowserWindow object
    kango.console.log(window.getId());
});

getTabs

KangoBrowserWindow.getTabs(callback)

Retrieves all tabs in window and pass it to callback function.

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

Example:

// output number of tabs in current window.
kango.browser.windows.getCurrent(function(win) {
    // win is KangoBrowserWindow object
    win.getTabs(function(tabs) {
        kango.console.log(tabs.length);
    });
});

getCurrentTab

KangoBrowserWindow.getCurrentTab(callback)

Retrieves current active tab in window and pass it to callback function.

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

Example:

// output url of current tab in current window.
kango.browser.windows.getCurrent(function(win) {
    // win is KangoBrowserWindow object
    win.getCurrentTab(function(tab) {
        // tab is KangoBrowserTab object
        kango.console.log(tab.getUrl());
    });
});

isActive

KangoBrowserWindow.isActive()

Return true if window is in focus and false if it is not.

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

Example:

// Find active tab in active window and open http://example.com/ in it
kango.browser.windows.getAll(function(wins) {
    // wins is an Array of KangoBrowserWindow objects
    for (var i = 0; i < wins.length; i++) {
        if (wins[i].isActive()) {
            // wins[i] is KangoBrowserWindow object representing active window
            wins[i].getCurrentTab(function(tab) {
                // tab is KangoBrowserTab objects for active tab in active window
                tab.navigate('http://example.com/');
            });
        }
    }
});