我正在开发chrome Extension。 创建了带有上下文菜单选项的复选框,它在Ubuntu(O / S)的Chrome浏览器(版本21.0.1180.15 beta)中运行良好。 但是在Windows-XP Chrome浏览器(版本23.0.1271.91)
中看不到复选框var contextMenuCallback = function(info, tab) {
console.log(info);
console.log(tab);
// we can do other stuff here.
}
var first_params = {
"id": "first_id",
"title": "First",
"type": "checkbox",
"checked": true,
"onclick": contextMenuCallback
};
var second_params = {
"id": "second_id",
"title": "Second",
"type": "checkbox",
"checked": true,
"onclick": contextMenuCallback
};
chrome.contextMenus.create(first_params);
chrome.contextMenus.create(second_params);
提出相同的建议。
答案 0 :(得分:1)
我使用相同的版本并且可以正常使用
您是否已检查上下文菜单的权限,如下所示。
<强>的manifest.json 强>
{
"name": "Context Menu Demo",
"description": "This gives demo of context menu features",
"version": "1",
"permissions": ["contextMenus"],
"background": {
"scripts": ["sample.js"]
},
"manifest_version": 2,
"icons":{"16":"screen.png","48":"screen.png","128":"screen.png"}
}
您是否已将代码包含在background.js
中
var contextMenuCallback = function(info, tab) {
console.log(info);
console.log(tab);
// we can do other stuff here.
}
var first_params = {
"id": "first_id",
"title": "First",
"type": "checkbox",
"checked": true,
"onclick": contextMenuCallback
};
var second_params = {
"id": "second_id",
"title": "Second",
"type": "checkbox",
"checked": true,
"onclick": contextMenuCallback
};
chrome.contextMenus.create(first_params);
chrome.contextMenus.create(second_params);
尝试使用此代码并向我们发送屏幕截图,以输出您期望的内容和缺少的内容?