How to check if there is an internet connection in Javascript? I have searched in Google but I have not found a good solution for my problem.
I have already got two eventhandler:
document.body.addEventListener("offline", function () {
//alert("offline")
masterViewModel.online(false)
}, false);
document.body.addEventListener("online", function () {
//alert("online")
masterViewModel.online(true);
}, false);
But how to check in the "onload"-function if I am online?
In HTML5, according to the specs:
var online = navigator.onLine;
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