Detect Internet Connection with JavaScript

Detect Internet Connection with JavaScript

Sometime, it becomes necessary to know about status of internet connectivity . We can know about internet connectivity in PHP also,but it is not good practice.

Using client side language to detect internet connectivity is good practice because it gives connection status without reloading a page.

So, using browsers property ( we can easily confirm the status of Internet connection.It returns online status of the browser.

Let’s us see snippet.


<button onclick="internetStatus();">Check Connection</button>   


function internetStatus()
alert("You are online");
alert("You are offline");

View Demo

Leave a Reply

Your email address will not be published. Required fields are marked *