HTML5 · Javascript · Professional

Detecting online/offline status

Detecting whether the browser is online or not.
navigator.onLine is working fine in Mozilla Firefox and Opera
Using the code

var onlineOfflineStatus=navigator.onLine ? ‘online’ : ‘offline’;

But this code not work in Chrome
Use ajax jquery

var connectSuccess = 0;
type: “POST”,
url: ‘onlineOfflineTested.php’,
cache: false,
dataType: “html”,
success: function(data){
connectSuccess = 1;
error:function (xhr, ajaxOptions, thrownError){
connectSuccess = 0;
if(connectSuccess == 1) {
} else {

url: onlineOfflineTested.php,onlineOfflineTested.cfm etc.
simple page with out any codding.

2 thoughts on “Detecting online/offline status

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s