[Project_owners] Repeating load events

Martin Hassman met at penguin.cz
Sun Sep 7 14:38:25 EDT 2003


On 6 Sep 2003 at 21:19, Andrew Kuttig wrote:

> The new Firebird extension I am working on requires that a function be 
> called when a document is done loading.  However, the function sometimes 
> requires significant processing time.  This wouldn't be a problem except 
> that the "load" event is triggered multiple times when a page is 
> loading.

Simple way is use:
window.addEventListener("load", my_onload_function, true);

But it will be called for HTML page loading and also for Chrome window 
loading.

> Is it supposed to do that?  Is there some way to detect the 
> actual final "load" call?

You can add you own webprogress listener (but this is a little bit more 
complicated and see also the bug #216900).

Or as simple solution you can use the notifyobserver of the browser 
webprogress listener and listen for "EndDocumentLoad" (this is called from 
the browser.js nsBrowserStatusHandler.endDocumentLoad )

function ano() { ... }
ano.prototype.observe = function (oSubject, sMessage, sContextUrl) { ... }

var anoano = new ano();

var oObserverService = Components.classes["@mozilla.org/observer-service;1"].getService();
oObserverService = oObserverService.QueryInterface(Components.interfaces.nsIObserverService);
oObserverService.addObserver(anoano, "EndDocumentLoad", false);

met

-- 
Martin Hassman
Jaky Internetovy prohlizec? Zkuste Mozillu http://www.czilla.cz/
Jabber: hassmanm(at)njs.netlab.cz, ICQ: #295399122



More information about the Project_owners mailing list