Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

runtime.onStartup

Fired when a profile that has this extension installed first starts up. This event is not fired when a private browsing (incognito) profile is started, even if this extension is operating in 'split' incognito mode.

Note:When using an event page or background service worker, the extension must add a listener toruntime.onStartup on the event page for the event page to be executed at least once per browser session.

Syntax

js
browser.runtime.onStartup.addListener(listener)browser.runtime.onStartup.removeListener(listener)browser.runtime.onStartup.hasListener(listener)

Event Functions

All events have three functions:

addListener(listener)

Adds alistener to the calling event.

removeListener(listener)

Stop listening to the calling event. Thelistener argument is the listener to remove.

hasListener(listener)

Checks whether alistener is registered for the calling event. Returnstrue if it is listening,false otherwise.

Parameters

The only parameter islistener, used for any of the above functions.

listener

The function called when this event occurs.

Examples

Openhttps://giphy.com/explore/cat when the browser starts up:

js
function handleStartup() {  browser.tabs.create({    url: "https://giphy.com/explore/cat",  });}browser.runtime.onStartup.addListener(handleStartup);

Browser compatibility

Note:This API is based on Chromium'schrome.runtime API. This documentation is derived fromruntime.json in the Chromium code.

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp