问题
I have created context menu & its child menus for selection of text using chrome.contextMenus.create but it creates multiple menus & sub-menus while testing. Can you tell me what is the prblem.
I am using code to create menus :
var contexts=["selection"];
var context = contexts[0];
var title = "Parent";
var id = chrome.contextMenus.create({"title": title, "contexts":[context]},function (){var child1 = chrome.contextMenus.create({"title": "child1", "contexts":[context], "parentId": id, "onclick": RecogniseNumber});
var child2 = chrome.contextMenus.create({"title": "child2", "contexts":[context], "parentId": id, "onclick": UnRecogniseNumber});
var child3 = chrome.contextMenus.create({"title": "child3", "contexts":[context], "parentId": id, "onclick": CallNumber}); });
来源:https://stackoverflow.com/questions/18378027/how-to-restirict-chrome-to-add-only-one-contextmenu