[英]Chrome Extension - Modify Right-Click Browser Action Menu
I am wondering if I am able to modify the right-click menu of the browser action menu? 我想知道我是否能够修改浏览器操作菜单的右键菜单? I want to add an option titled 'Logout'. 我想添加一个名为“Logout”的选项。
For the context Chrome says: 对于上下文Chrome说:
Value must be one of:
[all, page, frame, selection, link, editable, image, video, audio, launcher, browser_action, page_action]
值必须是以下之一:[all, page, frame, selection, link, editable, image, video, audio, launcher, browser_action, page_action]
So use 所以使用
chrome.contextMenus.create({
"title": "Logout",
"contexts": ["browser_action"],
"onclick": logout
});
Where logout()
is the function that will be called when you click on it. 其中logout()
是单击它时将调用的函数。 (And enable "contextMenus" permission in the manifest.) (并在清单中启用“contextMenus”权限。)
Edit: A bit of warning, if you have an Event page , using onclick
attribute is not supported and you should add a chrome.contextMenus.onClicked
handler instead. 编辑:有点警告,如果您有一个事件页面 ,则不支持使用onclick
属性,您应该添加chrome.contextMenus.onClicked
处理程序。
不,你不能这样做,你需要将它粘在浏览器动作弹出窗口中。
hum, if i understand ... you want add item on menu after right click? 哼,如果我明白了......你想在点击后在菜单上添加项目?
You can do this : 你可以这样做 :
chrome.contextMenus.create({
"title" : "You menu Name",
"type" : "normal",
"contexts" : ["link","video","audio"], //the context which item appear
"onclick" : shorten() // The function call on click
});
And your manifest : 你的清单:
Add "contextMenus" on "permissions" array. 在“permissions”数组上添加“contextMenus”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.