Alex Rivera | Logout

How do I get the window object for a specific tab if I have that tab's tabId?

Asked 2012-05-30T18:29:17.520
8

I have the tabId of a tab. How do I get it's window object?

Edit
Report

1 Answer

13

The window object as seen inside chrome extensions:

 chrome.tabs.get(YOUR_TAB_ID_HERE, function(tab){
      chrome.windows.get(tab.windowId, function(win){ 
           console.log(win); // THIS IS THE WINDOW OBJECT
      });
 });

But if you need the javascript runtime inside a specific tab, you'll need to use Content Scripts which are better explained here:

http://code.google.com/chrome/extensions/content_scripts.html

answered 2012-05-30T23:17:09.123

Your Answer