views:

28

answers:

1

I can get the URL of the current tab if I click on my extension. But if the extension is already open (user clicks on link that loads a webpage in the current tab, I don't get the current url.)

Here is the code I am using:

<script> 
           window.addEventListener("load", windowLoaded, false);
        function windowLoaded() {
          chrome.tabs.getSelected(null, function(tab) {
         document.getElementById('currentLink').innerHTML = tab.url;
          });
        }
</script>

    <div id="currentlink">Url will appear here</div>
A: 

If you want to see if a page is loaded in extensions, within your extension page (such as background, popup, etc), not content script, make use of the tab events that Chrome Extensions gives:

http://code.google.com/chrome/extensions/tabs.html#event-onUpdated

Mohamed Mansour

related questions