Detect offline online using JavaScript
close
Detect offline online using JavaScript

Detect offline online using JavaScript

Detect offline online using JavaScript

If you want to detect offline or online status of your client using JavaScript then this article will help you in that case.

You can detect weather your client is offline or online using single line of JavaScript code.

To simply detect the offline or online status of your client you can use the following JavaScript code.
if(navigator.onLine != true){return false}else{return true}

This is basically a conditional statement that will check the status. If your client is online then the script will return true else it will return false.

To make this easy to understand I have an example for you. You can copy this code and view its output. You will see that if you are online then you will see green color scheme otherwise you will see red color scheme.

Just simple go to this page and see the demo and if you want the source code you can also copy that from this demo page.

Click To View Demo

I hope it helped. Thank you.
Disqus Codes

No comments

Notifications

Disqus Logo