In Google Chrome, how would I get the URL of the page being shown on a specific tab?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With