chrome扩展学习 右键菜单实现代码

Tags: other
manifest.json

{
"name": "我的右键",
"description": "chrome扩展学习---menu使用",
"version": "0.1",
"permissions": ["contextMenus", "tabs"],
"background": {
"scripts": ["menu.js"]
},
"manifest_version": 2
}

menu.js

function genericOnClick(info, tab) {
alert(info.linkUrl);
}
function selectionOnClick(info, tab) {
alert(info.selectionText);
}
var link = chrome.contextMenus.create({"title": "链接地址","contexts":["link"],"onclick":genericOnClick});
var selection = chrome.contextMenus.create({"title": "选中文字","contexts":["selection"],"onclick":selectionOnClick});

本文链接:http://www.4byte.cn/learning/20761.html



相关问题