Prakash Pazhanisamy Prakash Pazhanisamy - 1 year ago 103
jQuery Question

Check the internet connection for each and every time of submission in JavaScript

Is there any possible way to check the internet connection for each and every time of submission in JavaScript?

Answer Source

You can use navigator.onLine to check the either there is internet connection or not. You can also use 2 event listener to notify when network connection is connected or disconnected.

console.log(navigator.onLine);

// OR

window.addEventListener('online', () => {
   //console.log('Online');
});

window.addEventListener('offline', () => {
        //console.log('Offline');  
});

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download