Skip to content Skip to sidebar Skip to footer

Chrome Extension Popup Installation

This is kind of a stupid question but i couldnt find any help searching around. I would like to know how can i make my chrome extension, when its being installed by a user, to redi

Solution 1:

For "when it is being installed", there is a special event in chrome.runtime API:

onInstalled

Fired when the extension is first installed, when the extension is updated to a new version, and when Chrome is updated to a new version.

As you guessed correctly, it should go to your background script.

chrome.runtime.onInstalled.addListener( function(details) {
  switch(details.reason) {
    case "install":
      // First installation
      break;
    case "update":
      // First run after an update
      break;
  }
});

To open a new tab with your URL, you can use chrome.tabs

chrome.tabs.create({url: "http://example.com/"});

Post a Comment for "Chrome Extension Popup Installation"