开发者

Chrome new tab event

开发者 https://www.devze.com 2023-01-17 04:18 出处:网络
I want to fire an event when a new tab is created in Chrome. I thought the following would do it, but it seems not. (beginner)

I want to fire an event when a new tab is created in Chrome. I thought the following would do it, but it seems not. (beginner)

manifest开发者_Python百科.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>


Are you just missing a closing ) bracket?

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

Because other than that your code works for me.

0

精彩评论

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