0
chrome.tabs.query({
    active: true,
    lastFocusedWindow: true
}, function (tabs) {
    // and use that tab to fill in out title and url
    var tab = tabs[0];
    console.log(tab.url);
    alert(tab.url);
});

This code shows me the URL in the alert() window, but I need to store this URL in a variable so I can store it or display it as I need.

Makyen
  • 31,849
  • 12
  • 86
  • 121
joee
  • 15
  • 6
  • var url = tab.url ? Be more explicit with the problem you are having – juvian Dec 14 '16 at 19:41
  • i need it outside the function it's ok if i need can create a var inside the function var url = tab.url ; but i need to use it outside – joee Dec 14 '16 at 20:08
  • 1
    Possible duplicate of [How do I return the response from an asynchronous call?](http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – Makyen Dec 14 '16 at 21:53
  • Also related:[Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference](http://stackoverflow.com/questions/23667086/why-is-my-variable-unaltered-after-i-modify-it-inside-of-a-function-asynchron). – Makyen Dec 14 '16 at 21:54

0 Answers0