2013-08-17 49 views
0

只是試圖創建一個簡單的標籤,我無法讓它工作。任何想法我做錯了什麼?Chrome擴展程序:無法創建標籤

的manifest.json

{ 
    "manifest_version": 2, 
    "browser_action": { 
     "default_icon": { 
      "19": "logo_19.png" 
     }, 
     "default_title": "Test Suite", 
     "default_popup": "main.html" 
    }, 
    "description": "Test Suite Description", 
    "icons": { 
     "128": "icon_128.png", 
     "16": "icon_16.png" 
    }, 
    "name": "Test Suite", 
    "permissions": ["http://www.google.com/"], 
    "version": "1.0" 
} 

main.html中

<html> 
<head> 
<script type="text/javascript" src="popup.js"> 
</script> 
</head> 
<body> 
    <div id="menu-items-ui">  
    <div id="registration"> 
    Google Search 
     </div> 
    </div> 
</body> 
</html> 

popup.js

<script type="text/javascript"> 
document.addEventListener('DOMContentLoaded', function() { 
    var registration = document.getElementById('registration'); 
    registration.addEventListener('click', function() { 
     chrome.tabs.create({ url: 'http://www.google.com' }); 
    }); 
}); 
</script> 

它是不會給谷歌網站。 在此先感謝。

回答

0

你在你的JavaScript文件有HTML,刪除它

popup.js

document.addEventListener('DOMContentLoaded', function() { 
    var registration = document.getElementById('registration'); 
    registration.addEventListener('click', function() { 
     chrome.tabs.create({ url: 'http://www.google.com' }); 
    }); 
}); 
+0

哎呀應該問之前已經注意到了這一點! – Samuel