Problem: Uncaught TypeError: Cannot read property 'onUpdated' of undefined
Google Chrome extension
My code:
main.js
I have a function getCookie and setcookie
var _a = getCookie("a");
if (_a != "") {
/// do something
} else {
chrome.tabs.onUpdated.addListener(function(tabId , info , tab) {
if (info.status == "complete") {
var _a = document.getElementsByName('id_loaded_page')[0].value;
setCookie("_a", value, 1);
console.log("_a: " +_a);
}
});
}