Are you trying to run this inside a content script? If so it won't work because content scripts have limited access to the extension APIs. Typically what you want to do is use messaging between a content script and a background page to have the background page call extension APIs on behalf of the content script. See the messaging section here:
http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/content_scripts.html#messaging Also look at the limitations section at the top of that doc page. <http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/content_scripts.html#messaging>If you're trying to run this from inside a background page, it should be working, but you might first try without the jquery stuff. Also make sure you've specified "tabs" inside the permissions entry of your manifest.json file. On Mon, Oct 26, 2009 at 2:54 PM, Bartek <[email protected]> wrote: > > Hi there, > > Trying to get some information from the currently selected Tab but I > am just getting an undefined object. This is using the dev build on > Windows XP if that matters: > > Here's some code. I even tried wrapping chrome.tabs.getSelected with > the windows.getCurrent function to ensure it's fetching the right one > but no go. I am guessing my issue may be that I'm using all this > inside a jQuery setup but I would like to verify it's the issue, and > hear on some better solutions: > > $(document).ready(function() { > $("#bookmark").click(function() { > var q; > chrome.windows.getCurrent(function(win) { > chrome.tabs.getSelected(win.id, function(tab) { > console.log(tab); > q = tab.url; > }); > }); > }); > }); > > Additionally, what's the proper way to test when building an > extension? Using console.log() doesn't output anything to the console > so it's very tough to play around with it. > > Thanks in advance and sorry if this has been answered before, I tried > searching. > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Chromium-extensions" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=en -~----------~----~----~----~------~----~------~--~---
