BrowserWindow.insert()
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);About this article
| Published in | Dev.Opera |
|---|---|
| Date | April 26, 2012 |
| Author | Opera Software |
| Tags | extensions API, Windows and Tabs |
| Original | Internet Archive |