Chrome Extension: In Tabs doc don't exist this

2019-07-21 00:50发布

as title I can't able find this method into the Api -> Tabs... Way and where? Thanks'

3条回答
成全新的幸福
2楼-- · 2019-07-21 01:00

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;
});
查看更多
▲ chillily
3楼-- · 2019-07-21 01:04

It was removed. Use chrome.tabs.query instead.

查看更多
虎瘦雄心在
4楼-- · 2019-07-21 01:09

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
    });
});
查看更多
登录 后发表回答