I'm doing a chrome extension, and there is in the doc this statement about chrome.tabs.onActivated.
Whenever I try to place chrome.tabs.onActivated.addListener, it says Uncaught TypeError: Cannot call method 'addListener' of undefined.
The whole background.html :
<script>
chrome.tabs.onActivated.addListener(function(info) {
var tab = chrome.tabs.get(info.tabId, function(tab) {
localStorage["current_url"] = tab.url;
});
});
</script>
The documentation is incomplete. As of Chrome 18, chrome.tabs.onActiveChanged is replaced with chrome.tabs.onActivated. In Chrome 17, the onActivated event did not exist.
chrome.tabs.onActivated.addListener( function(info) {
var tabId = info.tabId,
windowId = info.windowId;
});
chrome.tabs.onActiveChanged.addListener( function(tabId, info) {
tabId = tabId; // For comparison
var windowId = info.windowId;
});
I obtained this function name by opening the console in the context of an extension, and inspecting the keys of chrome.tabs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With