Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

runtime.onInstalled

Fired when the add-on is first installed, when the add-on is updated to a new version, and when the browser is updated to a new version.

Syntax

chrome.runtime.onInstalled.addListener(function(
  details // object
) {...})
chrome.runtime.onInstalled.removeListener(listener)
chrome.runtime.onInstalled.hasListener(listener)

This API is also available as browser.runtime.onInstalled.*.

Events have three functions:

addListener(callback)
Adds a listener to this event.
removeListener(listener)
Stop listening to this event. The listener argument is the listener to remove.
hasListener(listener)
Checks whether a listener is registered for this event. Returns true if it is listening, false otherwise.

addListener syntax

Parameters

function

Callback function that will be called when this event occurs. The function will be passed the following arguments:

details
object (see below).

Additional objects

details

reason
An runtime.OnInstalledReason value stating the reason that this event is being dispatched.
previousVersionOptional
string. Indicates the previous version of the extension that was just updated. This is present only if the reason value is update.
idOptional
string. Indicates the ID of the imported shared module extension that updated. This is present only if the reason value is shared_module_update.

Browser compatibility

Chrome Edge Firefox Firefox for Android Opera
Basic support Yes Yes No No 33

Examples

When the add-on is installed, log the install reason and open https://chilloutandwatchsomecatgifs.com/:

function handleInstalled(details) {
  console.log(details.reason);
  chrome.tabs.create({
    url: "https://chilloutandwatchsomecatgifs.com/"
  });
}

chrome.runtime.onInstalled.addListener(handleInstalled);

Acknowledgements

This API is based on Chromium's chrome.runtime API. This documentation is derived from runtime.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: Makyen, chrisdavidmills, wbamberg
 Last updated by: Makyen,