Powered By Blogger

Monday, November 29, 2010

WEB Progress Listener

  1. const STATE_START = Components.interfaces.nsIWebProgressListener.STATE_START;  
  2. const STATE_STOP = Components.interfaces.nsIWebProgressListener.STATE_STOP;  
  3. var myListener =  
  4. {  
  5.   QueryInterface: function(aIID)  
  6.   {  
  7.    if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||  
  8.        aIID.equals(Components.interfaces.nsISupportsWeakReference) ||  
  9.        aIID.equals(Components.interfaces.nsISupports))  
  10.      return this;  
  11.    throw Components.results.NS_NOINTERFACE;  
  12.   },  
  13.   
  14.   onStateChange: function(aWebProgress, aRequest, aFlag, aStatus)  
  15.   {  
  16.    // If you use myListener for more than one tab/window, use  
  17.    // aWebProgress.DOMWindow to obtain the tab/window which triggers the state change  
  18.    if(aFlag & STATE_START)  
  19.    {  
  20.      // This fires when the load event is initiated  
  21.    }  
  22.    if(aFlag & STATE_STOP)  
  23.    {  
  24.      // This fires when the load finishes  
  25.    }  
  26.   },  
  27.   
  28.   onLocationChange: function(aProgress, aRequest, aURI)  
  29.   {  
  30.    // This fires when the location bar changes; i.e load event is confirmed  
  31.    // or when the user switches tabs. If you use myListener for more than one tab/window,  
  32.    // use aProgress.DOMWindow to obtain the tab/window which triggered the change.  
  33.   },  
  34.   
  35.   // For definitions of the remaining functions see related documentation  
  36.   onProgressChange: function(aWebProgress, aRequest, curSelf, maxSelf, curTot, maxTot) { },  
  37.   onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage) { },  
  38.   onSecurityChange: function(aWebProgress, aRequest, aState) { }  
  39. }  

No comments:

Post a Comment