开发者

How could I make an extension that open a url when the icon is clicked?

开发者 https://www.devze.com 2023-03-12 05:28 出处:网络
There will be an icon in Chrome\'s extension bar, I\'d like to ope开发者_C百科n a link in a new tab when the icon is clicked(instead of popup a popup page). How could I do that?In your background page

There will be an icon in Chrome's extension bar, I'd like to ope开发者_C百科n a link in a new tab when the icon is clicked(instead of popup a popup page). How could I do that?


In your background page:

chrome.browserAction.onClicked.addListener(function() {
  chrome.tabs.create({url: "http://www.google.com"});
});

Google documentation for

  • chrome.browserAction.onClicked
  • chrome.tabs.create
0

精彩评论

暂无评论...
验证码 换一张
取 消