Connect with us

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

kizinho

Published

on

Follow
NEWS: Easy way on how to Check Internet Connection exists or not using Javascript when on a website. [New  Developer] » Naijacrawl
Photo: Naijacrawl
site

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

Click Here To Comment


site


kizinho

Adike Kizito is a top-rated software developer, blogger, sports, and entertainment lover. He is the CEO of these popular websites Naijacrawl.com and Mp3ager.com. He operates his software developing task through Kizzsoft.com,... Read More

Continue Reading
Click to comment

Be first to comment


    Leave a Reply

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

    Latest


    Download Naijacrawl App today

    Fastest way to read on the go

    Download the Naijacrawl App.