« Documentation Home

BrowserWindow.insert()

This documentation relates to Opera's now deprecated .oex Extension API framework for Opera versions <= 12.15 and also provided by our OEX2NEX shim library.

For the latest Opera Extensions API documentation for Opera versions > 12.15 please consult the latest Opera Extensions API documentation online.

Description:

The insert() method provides a way to insert a specified browser tab group or browser tab into this browser window, before the specified child, if provided.

Parameters:

Syntax:

void insert (BrowserTabGroup tabGroup, optional BrowserTabGroup child)

void insert (BrowserTab tab, optional BrowserTabGroup child)

void insert (BrowserTab tab, optional BrowserTab child)

Example:

The following example creates a button in the browser toolbar. When the button is clicked, the currently selected tab is detected. Then, a new browser window is created and the tab is inserted into it.

//
// The background process (e.g. index.html) 
//

// Specify the properties of the button before creating it.
var UIItemProperties = {
  disabled: false,
  title: "Window creation test",
  icon: "images/icon_18.png",
  onclick: function() {
    // Get the currently selected tab
    var thisTab = opera.extension.tabs.getSelected();
    
    // Open a new browser window
    var win = opera.extension.windows.create();
    
    // Insert the tab into the new window
    win.insert(thisTab);
  }
};

// Create the button and add it to the toolbar.
var button = opera.contexts.toolbar.createItem( UIItemProperties );  
opera.contexts.toolbar.addItem(button);