1
我正在尝试为Chrome创建右键单击上下文菜单。 我希望能够突出显示文本,点击右键,然后点击打开一个新的标签页,使用突出显示的文本确定的URL。Chrome右键单击上下文菜单
我有一个明显的(虽然我不知道我已经做了背景部分右):
{
"manifest_version": 2,
"name": "ClickMenu",
"version": "1.0",
"description": "A right-click context menu",
"icons": {
"16": "icons/icon-16.png",
"48": "icons/icon-48.png",
"128": "icons/icon-128.png"
},
"permissions": [ "contextMenus" ],
"background": {
"scripts": ["contextMenu.js"],
"persistent": false
}
}
并有contextMenu.js:
function MenuContext(contextInfo, tab) {
chrome.tabs.create({
'url' : 'https://myurl.com/' + contextInfo.selectionText + '/launch'
});
}
var contextId = chrome.contextMenus.create({
'title' : 'Launch this',
'contexts' : [
'selection'
],
'onclick' : MenuContext
});
它不工作。我可以加载扩展,但没有上下文菜单或功能。
你能看到我做了什么错?
这似乎对我很有用。 [Chrome扩展中的上下文菜单](http://stackoverflow.com/questions/13783500/context-menus-in-chrome-extensions) –