« Documentation Home

BrowserTab.locked

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:

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