[Project_owners] Two Mozilla questions (how to get the size of a document and about onload eventlisteners)

Håvar Henriksen havar at henriksen.nu
Wed Mar 9 01:02:45 EST 2005

Neil skrev:

> Håvar Henriksen wrote:
>> doron on #mozilla said that I should use a webProgressListener 
>> instead of a eventListener, but I'm not sure how to do that.
> Basically copy nsBrowserStatusHandler.js ;-)
> The notifications you're interested in are probably either 
> onLocationChange (which fires when the value in the URL bar needs to 
> change) or onStateChange (which fires when the throbber or progress 
> meter need to change).
> _______________________________________________

Hmm... that was to complicated, but I found out how to do it an eaiser 
way, by doing it the way the Live Bookmark RSS button shows up.
Just added this check inside the headerinfoWatcher.updateStatus(event) 
 if (event.originalTarget == _content.document)

I also added a setTimeout to the onload event. (I saw that it was done 
this way in the browser.js file so I thought I should do it the same way)
gBrowser.addEventListener("load", function(evt) { 
setTimeout(headerinfoWatcher.updateStatus, 0, evt); }, true);       

Now I only need to find a way to get the size of the current loaded 
document. (As I said earlier, not as it's done in the pageinfo dialogbox 
because that shows the compressed size if the document has been content 

If I find a way of maybe doing a String.length on e.g. the data that the 
view-source: window shows (because it could show the source of the 
cached document without needing to get that data again, AFAIK)

Håvar I. Henriksen
Community Manager Mozilla Norge || "To err is human, to forgive is
havar at firefox.no                || divine - but to forget it altogether
home.no.net/havarhen            || is humane."
firefox.no norwegian Mozilla resource

More information about the Project_owners mailing list