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.



The readonly url attribute exposes the document URL of the browser tab. On getting, the implementation returns the URL of the current document if the tab is open, otherwise it returns an empty string.


When specified as an item in a BrowserTabProperties object, the url property specifies the location for a browser tab as a URL.

When creating a browser tab, if this property is not specified the browser will use its default URL.

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



readonly string url


DOMString url


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

    // 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 = '';
    } else {
        tabProps.url = '';

    // Open a new tab with the relevant URL

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

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


No new comments accepted.