Here is the simple javascript function for getting internet status working or not..
<script> function checkInternetCon() { var status = navigator.onLine; if (status) { alert("Yes!! Working"); } else { alert("Sad!! Not Working "); } }</script>
 
 
 
 
Call above function on button onclick event.
 
 
<button onclick="checkInternetCon()">Check Internet Connection</button>
 
 
You can also use setInterval method in javascript
 
 
setInterval(function(){ 
var status = navigator.onLine;
 if (status) {
 console.log('Working..');
 } else {
  console.log('Not Working..');
 }
}, 5000); 
 
  
 
No comments:
Post a Comment