Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get URL of a specific tab?

In Google Chrome, how would I get the URL of the page being shown on a specific tab?

like image 464
Skizit Avatar asked Feb 07 '11 14:02

Skizit


1 Answers

This depends on how you define specific tab. There are numerous functions to get a tab, which in turn give you back a Tab object. This object has a url attribute.

Let's take the current selected tab for example. You get a handle on it with chrome.tabs.getSelected. Where null is a WindowID, and defaults to the current window.

chrome.tabs.getSelected(null, function(tab) { 
    alert(tab.url);
})

For more information I suggest you have a look at the documentation of the API.

like image 75
Reiner Gerecke Avatar answered Sep 27 '22 19:09

Reiner Gerecke