【发布时间】:2014-04-02 20:21:59
【问题描述】:
我想使用 Chrome 扩展程序创建一个新选项卡,并在加载选项卡时显示 tab.id。页面已加载,但回调函数不起作用(现在显示tab.id 的警报)。
background.js 文件:
chrome.tabs.create({'url': 'http://www.google.com'}, function(tab){ alert(tab.id) })
manifest.json 文件:
{
"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"
]
}
popup.html 文件:
<html>
<head>
<title>Test tabs</title>
</head>
<body>
<script type="text/javascript" src=/background.js"></script>
</body>
</html>
可能是什么问题?
【问题讨论】:
标签: javascript google-chrome google-chrome-extension