如何在chrome开发人员工具中使用控制台获取当前选项卡ID?

时间:2016-07-28 07:22:05

标签: javascript google-chrome

我是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?

修改 这些都不起作用,由于相同的"未定义"错误。

how to get current tabId from background page

How can I get the current tab URL for chrome extension?

0 个答案:

没有答案