Alex Rivera | Logout

Google Chrome Extension get page information

Asked 2011-07-29T09:47:07.737
12

I'm making a google chrome extension, and I need to get the current page URL and title. How can I achieve this?

Edit
Report

1 Answer

7

The method getSelected() has been deprecated since Google Chrome 16 (but many articles in the official documentation had not yet been updated). Official message is here. To get the tab that is selected in the specified window, use chrome.tabs.query() with the argument {'active': true}. So now it should looks like this:

chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
  console.log(tabs[0].url);
  console.log(tabs[0].title);
});

Edit: tabs[0] is the first active tab.

answered 2013-01-15T20:59:18.220

Your Answer