Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect from a Chrome Extension Popup [duplicate]

How do I make it that when I click my extension button in the upper right, it redirects me to another page? My manifest looks a little something like this.

{
  // Extension Info
  "manifest_version": 2,
  "name": "Extension",
  "version": "0.0.1",
  "description": "Text",

  // Action
  "browser_action": {
    "default_icon": "icon_64.png",
    "default_popup": "popup.htm"
   },

  // Other decorative stuff
  "icons": {
      "128": "icon_128.png",
      "64": "icon_64.png",
      "16": "icon_16.png"
   }
}

And popup looks like this

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript">
            window.open("http://website.com",'_blank');
        </script>
    </head>
    <body>
        <h1>Redirecting...</h1>
    </body>
</html>

Any Ideas? Thanks! -SensiAking1

like image 843
a4x Avatar asked Nov 09 '22 02:11

a4x


1 Answers

In background script, implement an onclick handler for browserAction button as follows.

chrome.browserAction.onClicked.addListener(function (tab) {
  chrome.tabs.update({ url: "http://website.com" });
});
like image 60
Nandu Avatar answered Nov 14 '22 22:11

Nandu