Dave Gordon
Dave Gordon

Reputation: 29

Chrome.Browser.Extension Errors: Uncaught TypeError and Unchecked runtime.lastError:

Ok, I am getting two errors with my Extension for chrome, The first error is

Uncaught TypeError: Cannot read property 'addListener' of undefined

with the second error being:

Unchecked runtime.lastError

They both occur in the same javascript file, which is as follows:

var contextMenuItem = {
"id": "RemoveItReportItRecordIt",
"title": "Remove It",
"contexts" : ["all"]
};

chrome.contextMenus.create(contextMenuItem);

chrome.contextMenus.OnClick.addListener(function(clickData) {
    if(clickData.menuItemId == "RemoveItReportItRecordIt")
      {
      if(clickData.SelectionText) return;
      else 
         alert("ClickData = " + clickData);
     }
});

Can you tell me and show me what I a doing wrong?

Upvotes: 0

Views: 183

Answers (1)

Andrew Myers
Andrew Myers

Reputation: 2786

The correct name of the event is onClicked, not OnClick. Using past tense in the event names seems to be fairly common in Chrome's extension API.

Upvotes: 2

Related Questions