Brian King wrote:
What is the best way for an extension to detect if a user is
online/offline? I'm not talking about, for example, the Work Offline
feature in Firefox, but rather about whether they have an internet
connection at the time a particular piece of code is executing.
What about something like:
var xmlRequest = new XMLHttpRequest();
xmlRequest.open("HEAD", aURL, true);
xmlRequest.onerror = function(aEvent)
{
var request, status;
try {
request = aEvent.target;
status = request.status;
}
catch(ex) {
request =
aEvent.target.channel.QueryInterface(Components.interfaces.nsIRequest);
status = request.status;
}
if (status > ) {
see:
http://lxr.mozilla.org/seamonkey/source/netwerk/base/public/nsNetError.h
}
blablabla...
}
xmlRequest.onload = function() { do something }
/HJ
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners