I am writing a Firefox add-on that does something after the web page is fully loaded.
My current code
var target = this; const STATE_STOP = Components.interfaces.nsIWebProgressListener.STATE_STOP; const STATE_IS_WINDOW = Components.interfaces.nsIWebProgressListener.STATE_IS_WINDOW; const STATE_IS_DOCUMENT = Components.interfaces.nsIWebProgressListener.STATE_IS_DOCUMENT; const locationChangeListener = { onStatusChange: function(){}, onProgressChange: function(){}, onLocationChange: function(aWebProgress, aRequest, aLocation){}, onStateChange: function(aWebProgress, aRequest, aFlag, aStatus){ if((aFlag & STATE_STOP) && (aFlag & STATE_IS_WINDOW)){
It works great. But sometimes, for example, a web page with an AJAX call, this event was fired several times for one web page.
Is there a way to detect if a webpage is fully loaded or not?
source share