BrowserTab.locked

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:

Attribute

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

Property

When specified as an item in a BrowserTabProperties object, the locked property indicates the desired locked state of a browser tab. The value true indicates that the tab should be locked, whereas the value false indicates that the tab should be unlocked.

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

When updating a browser tab, if this property is not specified, the default behaviour is to leave the locked state unchanged.

Syntax:

Attribute

readonly boolean locked

Property

boolean locked

Example:

The following example creates a button on the browser toolbar. When the button is clicked, the current tab is detected and is then locked (pinned).

//
// 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() {
    // Detect the currently selected tab
    var thisTab = opera.extension.tabs.getSelected();

    // Make the current tab locked (pinned)
    thisTab.update({locked: true});
  }
};

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