views:

288

answers:

1

I am going through the "Hello World" example on the Chrome dev pages (http://code.google.com/chrome/extensions/getstarted.html).

One thing I would like to do is to be able to grab the current selected tabs location.href and document.title.

For example if I am on www.apple.com and click the popup toolbar button I'm not sure how to access the www.apple.com document.

A: 

From what "parts" of the extension?

E.g. An extension's "background page"?
The "tab" object contain the "url" (location.href in DOM terms ) parameter.

You'll have to communication between a "content script" and the background page. Once you have a communication channel, you can grab the tab_id and refer to #1 above.


You can always grab the current window/tab: have a look here. You can grab the tab_id.url from thereon.

jldupont
Exactly. I guess I'm looking for the background page when in the context of a popup"browser_action": { "default_icon": "toolbarButton.png", "popup": "popup.html" }Thanks for the response. I will see what I can find for communicating to that background page.
ibuck

related questions