从Chrome扩展程序弹出窗口重定向

时间:2015-11-07 01:00:13

标签: javascript html google-chrome google-chrome-extension

如何点击右上方的扩展按钮,将其重定向到另一个页面? 我的清单看起来有点像这样。

{
  // 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"
   }
}

popup看起来像这样

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

任何想法? 谢谢! -SensiAking1

1 个答案:

答案 0 :(得分:0)

在后台脚本中,为browserAction按钮实现onclick处理程序,如下所示。

chrome.browserAction.onClicked.addListener(function (tab) {
  chrome.tabs.update({ url: "http://website.com" });
});
相关问题