A pedant that hangs out in the dark corner-cases of the web.

Saturday, August 26, 2006

Firefox: Using nsIWebProgressListener

Searching for many hours for an example of how to create and register an object that implements nsIWebProgressListener, I finally found this comment buried in an unrelated post that unlocked everything for me:

Are you looking for nsIWebProgressListener?

top.getBrowser().addProgressListener(...a listener object);

A minimal object:


var progressListener = {
stateIsRequest:false,
QueryInterface : function(aIID) {
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
aIID.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
},
onStateChange : function(aProgress,aRequest,aFlag,aStatus) {return 0;},

onLocationChange : function(aProgress,aRequest,aLocation) {
return 0;
},
onProgressChange : function(a,b,c,d,e,f){},
onStatusChange : function(a,b,c,d){},
onSecurityChange : function(a,b,c){},
onLinkIconAvailable : function(a){}
};

Jeremy Dunck - 29th April 2005 04:28

Some additional info can be found at mozillaZine: Just Before Page Load Event?

Tuesday, August 15, 2006

IE vs MIME headers

One of the most irritating and mysterious behaviors of IE is how it determines file type. The first thing it does is basically ignore the MIME type the server introduces the data with, then it samples the data and does whatever the hell it pleases.

Trying to support users who are trying to download CSV data, for example, but instead get it displayed in the browser can be incredibly time consuming. It's usually just easier to suggest they use Firefox.