Another way to describe my problem above is that I want to capture
URL/Title/H1 of every URL going to be opened in new tab or existing tab.
OnLoc routine only helps to capture those info of LOADED tab, ie the page is
loaded so the HTML DOM tree has been populated. But for url being opened in
new Tab, onLoc is not helpful as when onLOc is called, the DOM tree hasn't
been populated so getElementsByTagName('title') is null.
So I can add NewTabAdded() to listen in onLoc:
gBrowser.tabContainer.addEventListener("TabOpen", newTabAdded,
false);
But this result in the fact an URL will be submitted twice. Once in onLoc
and once in NewTabAdded. I am thinking of using an array to keep tracking
all URL open'ed. But I wonder if there is a more elegant way to do so.
--
Li Hong
What problem are you trying to solve? I don't understand.
Eric
When I try to use document.getElementsByTagName('title') in onLocationChange
event, it returns null object. I guess that's because this onLoc event is
fired as soon as I enter an URL in in the address bar. Thus the html
document has been populated yet. Is my understanding correct?
Also curious to know if I can listen to a diff event within another event.
Say, to make sure my getElementsByTagName() will work, I may listen to
load() event inside onLocationChange()?
Thanks,
> --
> Li Hong
>
>
>
--
Li Hong
> Hi list,
>
> When I try to use document.getElementsByTagName('title') in
> onLocationChange
> event, it returns null object. I guess that's because this onLoc event is
> fired as soon as I enter an URL in in the address bar. Thus the html
> document has been populated yet. Is my understanding correct?
>
>
I don't know, but you can ensure document.getElementsByTagName('title') is
called after window load and domcontentloaded with this:
https://developer.mozilla.org/en/Code_snippets/On_page_load#Attaching_a_script
Note the use of both load and DOMContentLoaded events.
Eric