In a standalone XUL app, I'd like to catch the server not found
exception. I've tried by checking state in onStateChange
event of the nsIWebProgressListener
, but this doesn't seem to work. My onStateChange
event implementation is as shown below. I'm making the assumption that if STATE_START
or STATE_STOP
is not returning a valid value, then there's something wrong with page loading, and displays the error message to the user.
onStateChange: function(aProgress, aRequest, aFlag, aStatus) {
const STATE_START = Components.interfaces.nsIWebProgressListener.STATE_START;
const STATE_STOP = Components.interfaces.nsIWebProgressListener.STATE_STOP;
if(aFlag & STATE_START) {
document.getElementById("progressBar").hidden = false;
}
if(aFlag & STATE_STOP) {
setTimeout(function() { document.getElementById("progressBar").hidden = true; }, 2000);
}
if(aFlag & (!STATE_START | !STATE_STOP)) {
alert("Your connection seems to be down. Please confirm with your system admin.");
}
return 0;
},
Can someone kindly advice me on what I'm doing wrong? Thanks in advance.