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 disabled
attribute represents whether a menu item is visible in a context menu. If the value is false
(default), the menu item will be displayed and is clickable, whereas if the value is true
the item will not be displayed in the context menu.
Boolean false
In the following example, a menu item is created for translating the web page into English. The menu item is disabled (not visible) if the user's browser language is not set to English.
<!--
The configuration file ('config.xml').
-->
<?xml version='1.0' encoding='utf-8'?>
<widget xmlns="http://www.w3.org/ns/widgets">
...
<feature name="opera:contextmenus"/>
...
</widget>
//
// The background process (e.g. index.html)
//
if (opera.contexts.menu) {
var menu = opera.contexts.menu;
// Create a menu item properties object
var itemProps = {
title: 'Translate page into English',
onclick: function(event) {
doTranslate(event.pageURL);
}
}
if (window.navigator.browserLanguage.indexOf('en') != 0) {
itemProps.disabled = true;
}
// Create a menu item with the specified properties
var item = menu.createItem(itemProps);
// Add the menu item to the context menu
menu.addItem(item);
}