We have many customers in remote areas and lost of connectivity is frequent. How can I detect if the javascript app is offline? Meaning cannot reach the server and load the templates.
I finally found a JSFiddle that does exactly that: Check if the web application is online. It uses window.navigator.onLine
.
JSFiddle: http://jsfiddle.net/rommsen/QY8w2/
Source: https://groups.google.com/d/msg/angular/ZncvSVUc9y4/S4jH1e_XgGoJ
$scope.online = $window.navigator.onLine;
$window.addEventListener("offline", function() {
$scope.online = false;
});
$window.addEventListener("online", function() {
$scope.online = true;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With