I've try to use code from this question: How to detect `focusin` support?
but for Chromium that supports offline
event hasEvent('offline')
return false. Anybody know how to detect offline/online events in JavaScript?
I've try to use code from this question: How to detect `focusin` support?
but for Chromium that supports offline
event hasEvent('offline')
return false. Anybody know how to detect offline/online events in JavaScript?
Try:
return !!window.applicationCache;
If I understand properly your question, you also may want to read this article.
EDIT:
Basically you can use the following function:
function reportConnectionEvent(e)
{
if (!e) e = window.event;
if ('online' == e.type) {
alert( 'The browser is ONLINE.' );
}
else if ('offline' == e.type) {
alert( 'The browser is OFFLINE.' );
}
else {
alert( 'Unexpected event: ' + e.type );
}
}
window.onload = function() {
document.body.ononline = reportConnectionEvent;
document.body.onoffline = reportConnectionEvent;
}
Also you may check this for demo http://html5demos.com/offline-events
You can try
'onoffline' in window
or
'onoffline' in document.body
It seems that online and offline events start on body and bubble up so you can't use div to detect it. But I've created this code:
var body = document.getElementsByTagName('body')[0];
body.setAttribute('ononline', 'return;')
typeof body.ononline == 'function';