Answer the question
In order to leave comments, you need to log in
Chrome extension contextMenus Api can't add OnClick handler?
I am trying to create a chrome extension. Currently I'm going to create a context menu for my extension that will do something when I click on it. So, following Google documentation I create a context menu.
chrome.runtime.onInstalled.addListener(function() {
var context = "selection";
var title = "Google for Selected Text";
var id = chrome.contextMenus.create({"title": title,
"contexts":[context],
"id": "context" + context
});
});
...
onclick : function() { alert("work") }
chrome.contextMenus.onClicked.addListener(onClickHandler);
Answer the question
In order to leave comments, you need to log in
Add the handler immediately when creating the context menu element.
downloadItem = chrome.contextMenus.create
(
{
id: "utilsExtDownloadMenuItem",
parentId: rootItem,
title: "Загрузить...",
contexts: ["all"],
onclick: downloadContent
},
function(){}
);
........
function downloadContent(info, tab)
{
........
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question