[英]Does chrome.runtime.onInstalled fire when loading unpacked extensions?
I'm testing out my chrome plugin and trying to test out chrome.runtime.onInstalled
. 我正在测试chrome插件,并尝试测试
chrome.runtime.onInstalled
。
My code is as following 我的代码如下
function installed(){
alert("Success");
}
chrome.runtime.onInstalled.addListener(installed);
But when loading the extensions through loading unpacked extension
. 但是当通过
loading unpacked extension
。 I don't get any alert at all. 我一点也没有收到任何警报。 `chrome.runtime.onInstalled doesn't seem to fire.
chrome.runtime.onInstalled似乎没有启动。 How can I test this?
我该如何测试?
The above code resides in popup.js
and is called in a script tag from popup.html
. 上面的代码位于
popup.js
并在popup.js
的脚本标签中popup.html
。 The manifest.json
file for that section looks like the following. 该部分的
manifest.json
文件如下所示。
"browser_action": {
"default_icon": {
"19": "images/enabled-icon-19.png"
//"38": "images/icon38.png"
},
"default_popup": "popup.html",
"default_title": "mytitle"
}
For chrome.runtime.onInstalled
to run you need to edit your manifest.json
file and add 为了使
chrome.runtime.onInstalled
运行,您需要编辑manifest.json
文件并添加
"background": {
"scripts": ["background.js"]
}
Put the chrome.runtime.onInstalled.addListener(installed);
将
chrome.runtime.onInstalled.addListener(installed);
line there along with all the required functions. 线以及所有必需的功能。 Then it will work as expected.
然后它将按预期工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.