« Documentation Home

BrowserWindow.private

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 private attribute exposes the privacy mode of the browser window. On getting, the private attribute returns true if the privacy mode of the browser window is private, otherwise it returns false.

Property

When specified as an item in a BrowserWindowProperties object, the private property indicates the desired privacy mode of a browser tab. The value true indicates that the window should be private. The value false indicates that the privacy mode should be set to normal.

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

When updating a browser window, this property has no effect, whether specified or not. In other words, the privacy mode remains unchanged.

Syntax:

Attribute

readonly boolean private

Property

boolean private

Example:

The following example creates a button in the browser toolbar. When the button is clicked, the last focused window is detected. A new tab is then created with different URL depending on whether the window is private or not.

//
// 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() {
    // Get the last focused window
    var thisWin = opera.extension.windows.getLastFocused();
    
    // Create an empty tab properties object
    var tabProps = {};
    
    // Add a tab URL depending on whether the window is private or not
    if (thisWin.private) {
        tabProps.url = 'http://www.facebook.com/';
    } else {
        tabProps.url = 'http://www.wikipedia.org/';
    }
    
    // Open a new tab with the relevant URL
    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);