Saturday, 17 August 2013

Chrome extension: cannot create tab

Chrome extension: cannot create tab

Just trying to create a simple tab and I cannot get it to work. Any ideas
what I am doing wrong?
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>
It is not going to the google site. Thanks in advance.

No comments:

Post a Comment