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.
A reference to the window
object of the background process. The bgProcess
object can be used to set and get variables and functions between the background script and a popup window or preferences page. Note that it cannot be used in injected scripts for security reasons.
The value of a variable in the background process is displayed when the preferences page is opened.
//
// The background process ('/background.js').
//
var data = 'This is some important data in the backround process';
//
// An extension environment (e.g. '/options.js')
//
window.addEventListener('DOMContentLoaded', function() {
var myElement = document.createElement('p');
myElement.textContent = opera.extension.bgProcess.data;
document.body.appendChild(myElement);
}, false);
Executing a function in the background process from the preferences page.
//
// The background process ('/background.js').
//
function doReverse(text) {
var output = '';
for (var i = text.length - 1; i >= 0; i--) {
output += text.charAt(i);
}
return output;
}
//
// An extension environment (e.g. '/options.js')
//
window.addEventListener('DOMContentLoaded', function() {
var reversedText = opera.extension.bgProcess.doReverse('enihcam ym no skrow tI');
}, false);