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