BrowserWindow.width

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:

When specified as an item in a BrowserWindowProperties object, the width property specifies the desired width of a browser window.

When creating a browser window, if this property is not specified the browser's default width is used.

When updating a browser window, if this property is not specified the default behaviour is to leave the height unchanged.

Syntax:

unsigned long width

Example:

The following example creates a button on the browser toolbar. When the button is clicked, a new window is created with the specified height, width, top offset and left offset.

//
// 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"
};

// Create the button and add it to the toolbar.
var button = opera.contexts.toolbar.createItem( UIItemProperties );
opera.contexts.toolbar.addItem(button);

button.addEventListener('click', handleClick, false);

function handleClick() {
  // Set the properties for the window
  var windowProps = {
    height: 600,
    width: 400,
    top: 50,
    left: 100
  }

  // Create a new window using the specified properties
  opera.extension.windows.create({}, windowProps);
}

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

Comments

  • photo

    Dmitry Mironov

    Saturday, April 28, 2012

    This sample doesn't work properly. It opens the new window by click on the button, but all properties passed in 'windowProps' are ignored.

    Version 11.61, Build 1250, Platform Win32, System Windows 7
No new comments accepted.