Reputation: 3137
I am trying t. heo check if network connection is exist or not. here is some code
if (window.Connection) {
if (navigator.connection.type == Connection.NONE) {
window.localStorage.setItem("connectionType", '0');
} else {
window.localStorage.setItem("connectionType", '1');
}
} else {
alert("function doesnot run");
}
It is working fine on device and emulator. Can we check same on web browser
Thanks
Upvotes: 0
Views: 208
Reputation: 4477
Answer to your question is navigator.onLine
. It returns true if you are connected to some network..
Here's a snap from my browser
Upvotes: 1