クロム拡張機能を使用していますが、this statementについてはchrome.tabs.onActivated
です。Chrome tabs.onActivated.addListenerが「未定義」TypeErrorをスローします
chrome.tabs.onActivated.addListener
を置くと、いつでもUncaught TypeError: Cannot call method 'addListener' of undefined
と表示されます。
全体background.html:
<script>
chrome.tabs.onActivated.addListener(function(info) {
var tab = chrome.tabs.get(info.tabId, function(tab) {
localStorage["current_url"] = tab.url;
});
});
</script>
PS。これは私が使用したコマンドです: 'Object.keys(chrome.tabs).filter(function(name){return name.slice(0,2)== 'on'});'、戻り値: '[" onCreated 「onUpdated」、「onMoved」、「onSelectionChanged」、「onActiveChanged」、「onHighlightChanged」、「onDetached」、「onAttached」、「onRemoved」]「Chrome」17. –
これは完璧に動作します。 – azenet