BrowserTab.focused

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:

When specified as an item in a BrowserTabProperties object, the focused property indicates the desired focus state of a browser tab. The value true indicates that the tab should be focused, and false indicates that the focus state should not change.

When creating or updating a browser tab, if this property is not specified, the default behaviour is the same as specifying false.

Note: The focused property is only a hint. Certain conditions and platform conventions might cause a tab and its context window to be focused or not, regardless of the specified value.

Syntax:

boolean focused

Example:

The following example creates a button on the browser toolbar. When the button is clicked, a new tab is created with the specified URL and given focus.

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

// Specify the properties of the button before creating it.
var UIItemProperties = {
  disabled: false,
  title: "Example extension",
  icon: "images/icon_18.png",
  onclick: function() {
    // Create a tab properties object
    tabProps = {
      url: 'http://www.operamail.com/',
      focused: true
    };

    // Create a tab with the specified properties
    var tab = opera.extension.tabs.create(tabProps);
  }
};

// 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.