title: How can I get the current tab URL for chrome extension?
body: <p>I know there are many similar questions on SO, but I cannot seem to get it working.</p>
  
  <p>I am trying to get the URL of the current tab from my Chrome extension.  Hoewever, the alert(tab.url) returns "Undefined".  I have added the "tabs" to my permissions in the manifest.json.  Any ideas?</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
  
      chrome.tabs.getSelected(null, function(tab) {
          tab = tab.id;
          tabUrl = tab.url;
  
          alert(tab.url);
      });
  
  &lt;/script&gt;
  &lt;/head&gt;
  </code></pre>