Connect with us

Easy way on how to Check Internet Connection exists or not using Javascript when on a website.

kizinho

Published

on

Follow
Easy way on how to Check Internet Connection exists or not using Javascript when on a website.
Photo: Naijacrawl

Hi guys am here today again to show you guys on how to let a user know when internet connect is lost when a user browsing through your website or accidentally turn of the data connection.

 

With a simple line of code, you can achieve this by using a JavaScript plugin named offline.js

 

how it works


 Offline.js keeps  sending Ajax request to load an Image (1 byte in size) to check the connection. If that ajax call receives 200 Ok status code, then internet connection is UP. If it returns 204 No Content status code, then an Internet connection is Down.

Javascript

 

Implementing these is so easy by a few lines of code, you are done. No coding experience required, just copy and paste it

 

More articles like these navigate to our developer section and enjoy .

 

How to implement it 


Please place the below javascript before    tag

 

Load the below stylesheet before the tag. 1st CSS is for styling the theme. 2nd class is for language content.

 

 

See the live demo by Turning off your data connection while on naijacrawl.

 

Plenty cool right, congratulation you have successfully enabled these features on your website, don't forget to buy me beer using the donation button. You can donate with PayPal, visa card or master, even bitcoin.

 

Enjoy and share it.

For more visit Here


kizinho
 Follow

I am a software developer, like meeting people and love blogging, that's why I developed naijacrawl because that's what I love doing.

Continue Reading
Click To Comment

BE First To Comment


    Leave a Reply

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

    Latest



    Face of Naijacrawl


    ChukwubuikemSunday ChukwubuikemSunday

    Sunday Chukwubuikem


    Higher - 09061773292

    Trending