What Peter suggested is possible, although it is not stylish or does not follow best practices.
I supplement Jason Weathersby's answer with a code example and how this can be achieved.
Browser behavior
This is a very browser dependent implementation, you have to be careful when using these properties. As indicated in MDN,
Chrome Safari, (LAN) , ; . , , , , , ,
, .
Firefox Internet Explorer . .
navigator.onLine, (false/ undefined).
, , online = window.navigator.onLine;
, -
window.addEventListener("offline", function(e) {do something})
window.addEventListener("online", function(e) {do something})
, , . http://www.html5rocks.com/en/mobile/workingoffthegrid/, -
window.applicationCache.addEventListener("error", function(e) {
alert("Error fetching manifest: a good chance we are offline");
});
, , , , , . , : ( ), .