Check if connected to internet
Once I stuck with a problem that "How to check if connected to internet or not using JavaScript"
There could be different reasons for this kind of need.
1. Suppose one need to call an online script from JavaScript code
2. Start downloading a file etc
if(there is NO internet connectivity){ window.close(); } else{ Call a script OR download a file etc }
Solution is very simple. Simply Put an image tag in your HTML file and write code like this:
<img src="online-site-url/image.gif" onError="alert('Image missing or no internet connection')">
|
I hope it will help you guys.