Reputation: 2616
In my extension/addon background script I'm having issues trying to a new tab's url, it keeps coming back with 'about:blank', which is fair enough if it hasn't loaded properly yet.
My question is how do you get the url of a newly created tab as soon as it is ready?
browser.tabs.onCreated.addListener(function(tab) {
var m_Url = tab.url;
console.log("m_Url: " + m_Url);
});
Upvotes: 1
Views: 715
Reputation: 132
Use onUpdated instead.
Check the doc https://developer.chrome.com/extensions/tabs#event-onUpdated
Fired when a tab is created. Note that the tab's URL may not be set at the time this event is fired, but you can listen to onUpdated events so as to be notified when a URL is set.
So, onUpdated event is the appropriate event in this case.
Upvotes: 2