Checking if the browser is online

There is a easy way to check if the browser as internet access or not. In the wireless and mobile world a check if the loaded page has internet access can be very good, a very easy check can save you alot of problem.

The only thing you need to do is

if(navigator.onLine==true){
alert("Online")
}else{
alert("Offline")
}

Leave a Reply

4 Comments on "Checking if the browser is online"

Notify of
avatar
Sort by:   newest | oldest | most voted
mark roden
Guest

To be clear, does this mean that the browser is in offline mode or does it mean that has a valid internet connection?

Could be useful thanks 🙂

Stephan H. Wissel
Guest

Tense version:

alert(navigator.onLine ? “Online” : “Offline);

you don’t actually need a == true since it is boolean already;

wpDiscuz