BrowserWindow.insert()

By Opera Software

From Opera 15 onward, Opera 11 & 12’s extension format is no longer supported, and instead, we’ve switched to Chromium’s extension model. Check out our new documentation for developing extensions for Opera 15 and higher and start building your own extensions.

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:

  • tab / tabGroup: The tab or tab group to insert.
  • child (optional): The tab or tab group before which the specified tab or tab group should be inserted.

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);

This article is licensed under a Creative Commons Attribution 3.0 Unported license.

Comments

No new comments accepted.