BrowserWindow.private

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

This article is licensed under a Creative Commons Attribution 3.0 Unported license.

Comments

No new comments accepted.