Chrome new tab event

柔情痞子 提交于 2019-12-24 03:49:06

问题


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.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:


Are you just missing a closing ) bracket?

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

Because other than that your code works for me.



来源:https://stackoverflow.com/questions/3743072/chrome-new-tab-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!