I want to create a new tab using Chrome Extension and when tab is loaded to show tab.id
. Page is loaded but callback function is not worked (alert with tab.id
is now showed).
The background.js file:
chrome.tabs.create({'url': 'http://www.google.com'}, function(tab){ alert(tab.id) })
The manifest.json file:
{
"name": "Test",
"version": "1.0",
"description": "Test plugin",
"browser_action": {
"default_popup": "popup.html",
"default_icon":"icon.png"
},
"background": {
"scripts": ["background.js"]
},
"manifest_version":2,
"permissions": [
"tabs",
"http://*.facebook.com/*",
"http://*.google.com/*",
"storage"
]
}
The popup.html file:
<html>
<head>
<title>Test tabs</title>
</head>
<body>
<script type="text/javascript" src=/background.js"></script>
</body>
</html>
What can be a problem?