open new window chrome extension 1

open new window chrome extension

chrome.browserAction.onClicked.addListener(function(tab) {
  chrome.windows.create({
    // Just use the full URL if you need to open an external page
    url: chrome.runtime.getURL("mypage.html")
  });
});

Here is what the above code is Doing:
1. When the user clicks the extension icon, the browserAction.onClicked event is fired.
2. The event listener calls chrome.windows.create() to create a new window.
3. The window is created with the URL of the extension’s HTML page.

Similar Posts