当我点击浏览图标时,我想提醒一些消息,有我的代码,但它不起作用,有人可以帮助我吗?谢谢!
的manifest.json
{
"brower_action":{ "default_icon":"test.png"},
"background_page":"background.html",
"permissions":["tabs","http://*/*","https://*/"]
}
的script.js
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(
null, {code:"alert('test')"});
});
background.html
<html>
<head>
<script src="background.js"></script>
</head>
<body></body>
</html>
答案 0 :(得分:1)
script.js所需要的只是:
chrome.browserAction.onClicked.addListener(function(tab) {
alert('test');
});