Skip to content

Chrome Extension – Get Current Or Active Tab Id And URL

Chrome Extension – Get Current Or Active Tab Id And URL

Here’s a quick code snippet on how you can get your current tab details when developing a chrome plugin or extension. To get current tab id,
var tabId = chrome.tabs.getSelected(null, function(tab) {
    var tabId = tab.id;
    
    return tabId;
});
To get current tab url,
var tabUrl = chrome.tabs.getSelected(null, function(tab) {
    var tabUrl = tab.url;
    
    return tabUrl;
});
That’s all. Let me know if you need any assistance in the comments.
Enjoyed the content ? Share it with your friends !
Published inDevelopmentProgramming

Be First to Comment

Leave a Reply

Your email address will not be published.