Tabs.url is undefined

Posted by Notionwork on Stack Overflow See other posts from Stack Overflow or by Notionwork
Published on 2012-11-22T22:53:29Z Indexed on 2012/11/22 22:59 UTC
Read the original article Hit count: 109

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.url);
        $('#current-tab').append(tab.url);
    };
});

});

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery