Chrome新标签活动

时间:2010-09-18 19:10:54

标签: events google-chrome-extension

我想在Chrome中创建新标签时触发事件。我认为以下会这样做,但似乎没有。 (初学者)

的manifest.json

{
  "name": "My First Extension",
  "version": "1.0",
  "description": "The first extension that I made.",
  "background_page": "background.html",
  "permissions": [
    "tabs"
  ]
}

background.html

<html>
    <head>
        <script type="text/javascript">
            chrome.tabs.onCreated.addListener(function() {alert('hello new tab'});
        </script>
    </head>
    <body>
    </body>
</html>

1 个答案:

答案 0 :(得分:2)

您是否只是错过了结束)括号?

...{alert('hello new tab'});
                         ^

因为除此之外,您的代码适合我。