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.
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
.
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.
readonly boolean focused
boolean focused
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);