Developers › Dev.Opera

BrowserWindow.focused

April 26, 2012 · by Opera Software

Description:

Attribute

The readonly focused attribute exposes the focused state of the browser window. On getting, the focused attribute returns true if the browser window is focused, otherwise it returns false.

Property

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

When creating or updating a browser window, 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 window to be focused or not regardless of the specified value.

Syntax:

Attribute

readonly boolean focused

Property

boolean focused

Example:

The following example creates a button in the browser toolbar. When the button is clicked, a new, empty browser window is created and is then give focus.

//
// 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() {
    // Open a new browser window
    var win = opera.extension.windows.create();
    
    // Update the window to give it focus
    win.update({focused: true});
  }
};

// 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 inDev.Opera
DateApril 26, 2012
AuthorOpera Software
Tagsextensions API, Windows and Tabs
OriginalInternet Archive