Possible Duplicate:
After calling chrome.tabs.query, the results are not available
disclaimer: i'm a complete javascript n00b, be gentle.
popup.js:
var foo = '';
chrome.tabs.query({'active': true, 'windowId': chrome.windows.WINDOW_ID_CURRENT},
function(tabs){
foo = tabs[0].url;
}
);
document.getElementById("bar").innerHTML=foo;
This doesn't work as foo is undefined. I know by moving the document.getElementById into the function it works, but the point is I want foo to refer to a variable I can use later on in my popup.js