I have no clue what I'm doing wrong here! This should be working I believe. I'm writing a chrome extension and this should get the current tab's url and set the html of #current-tab to the url (for testing purposes). The code successfully gets to the callback, but it says that tab.url is undefined when I put it in an alert box, and it does not put it's value in #current-tab. Here's the code I have:
$('#get-tab').click(function(){ chrome.tabs.query({"active" : true}, function(tab){ for (var i = 0; i < tab.length; i++) { alert(tab[i].url); $('#current-tab').append(tab[i].url); }; }); });
tab[i].url?tab[i].url) as I knew that it returned an array, but that didn't seem to be working either, so I posted the script that I was trying instead, which didn't make much sense to me, but I was experimenting... See my edit above with my original code.