as title I can't able find this method into the Api -> Tabs... Way and where? Thanks'
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
It was deprecated in Chrome 16. The correct way is to use chrome.tabs.query
with active:true
and lastFocusedWindow:true
.
// Get the current active tab in the lastly focused window
chrome.tabs.query({
active: true,
lastFocusedWindow: true
}, function(tabs) {
// and use that tab to fill in out title and url
var tab = tabs[0];
run({
url: tab.url,
description: tab.title
});
});
回答2:
It was removed. Use chrome.tabs.query instead.
回答3:
https://developer.chrome.com/extensions/tabs#method-getSelected
It's a deprecated method, but you can still use it.
chrome.tabs.getSelected(null, function(tab) {
var url = tab.url;
});