« Documentation Home

BrowserTab.focused

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:

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