我是Javascript&的新手我想使用chrome开发人员工具的控制台获取当前打开的Google Chrome浏览器标签的ID。我尝试了下面的代码,但有一个例外。我该如何工作?我是否必须为这件小事学习更多东西?
chrome.tabs.getCurrent(function(tab){ console.log(
JSON.stringify(tab,null, 2)); });
例外:
Uncaught TypeError: Cannot read property 'getCurrent' of undefined(…)
VM1201:1 Uncaught TypeError: Cannot read property 'getCurrent' of undefined(…)
来源:Chrome how to get the current tab's id?
修改 这些都不起作用,由于相同的"未定义"错误。