perfect! and... sorry but... how to combine both? something like:
chrome.tabs.getSelected(null, function(tab){ chrome.tabs.onUpdated.addListener(function(tab.id, changeInfo, tab2) { // code here... }); }); or: chrome.tabs.onUpdated.addListener(function(<what_here?>, changeInfo, tab) { chrome.tabs.getSelected(null, function(tab){ // code here... }); }); On Nov 23, 8:34 pm, Rafael Weinstein <rafa...@chromium.org> wrote: > You need to listen to chrome.tabs.onUpdated event. > > http://code.google.com/chrome/extensions/tabs.html#event-onUpdated > > something like > > chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { > if (changeInfo.status == 'complete') { > tabUrl = tab.url; > tabTitle = tab.title; > createLink(); > } > > > > On Sun, Nov 22, 2009 at 11:59 AM, lorenx <lor...@gmail.com> wrote: > > ok, i did it. thank you! > > > but the tab is loading and the title is still not available... > > how to wait for the tab to be completly loaded? > > > On Nov 22, 5:27 am, donaddon <don...@verizon.net> wrote: > >> I'm not sure I understand what you are expecting, but getSelected is > >> an asynchronous call. So you can't expect tabUrl and tabTitle to be > >> set at the time you are currently calling createLink. They will only > >> be set when the callback function is called. You may be looking to do > >> something like this: > > >> chrome.tabs.getSelected(null, function(tab) { > >> tabUrl = tab.url; > >> tabTitle = tab.title; > >> createLink(); > > >> }); > > >> On Nov 21, 6:21 am, lorenx <lor...@gmail.com> wrote: > > >> > hi all, > >> > i have a problem getting current tab info. > > >> > var tabUrl; > >> > var tabTitle; > >> > function getTabInfo() { > >> > chrome.tabs.getSelected(null, function(tab){ > >> > console.dir(tab); > > >> > tabUrl = tab.url; > >> > tabTitle = tab.title; > >> > });} > > >> > function createLink() { > >> > console.log(tabUrl + '|' + tabTitle);} > > >> > getTabInfo(); > >> > createLink(); > > >> > what's wrong with this code? > >> > the tab object is output after createLink() is called... > >> > should i have to set up some communication system between components? > >> > thanks. > > > -- > > > You received this message because you are subscribed to the Google Groups > > "Chromium-extensions" group. > > To post to this group, send email to chromium-extensi...@googlegroups.com. > > To unsubscribe from this group, send email to > > chromium-extensions+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/chromium-extensions?hl=. -- You received this message because you are subscribed to the Google Groups "Chromium-extensions" group. To post to this group, send email to chromium-extensi...@googlegroups.com. To unsubscribe from this group, send email to chromium-extensions+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=.