kango.browser.windows

Summary

Name Description
getAll Retrieves all windows
getCurrent Retrieves current active window
create Creates new window

Methods

getAll

kango.browser.windows.getAll(callback)

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

Arguments:
  • callback (function(wins)) – callback function. wins ia an Array of KangoBrowserWindow objects

Example:

// enumerate all the browser windows, look for active window and output URL in selected tab for it
kango.browser.windows.getAll(function(wins) {
        // wins is Array of KangoBrowserWindows
        for (var i=0; i < wins.length; i++) {
                if(wins[i].isActive()) {
                        wins[i].getCurrentTab(function(tab1){
                                // tab1 is an active tab in active window
                                kango.console.log(tab1.getUrl());
                        });
                }
        }
});

getCurrent

kango.browser.windows.getCurrent(callback)

Retrieves currently active window and pass KangoBrowserWindow object for it to callback as argument.

Arguments:

Example:

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

create

kango.browser.windows.create(details)

Creates new window with specified parameters. Created tab window be in focus after creation.

Arguments:
  • details – create parameters

Details object:

details = {
        string url      // URL of the page to open
}

Example:

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