2010-09-18 74 views
3

我想在Chrome中創建新選項卡時觸發事件。我認爲下面會做,但似乎沒有。 (初級)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> 

回答

2

你只是缺少一個右括號)

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

因爲除了你的代碼適用於我。