JavaScript Check Internet Connection



    How does it work?

    It keeps on 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 Internet connection is Down.


    Please place the below javascript before </body> tag

    <script src="https://cdnjs.cloudflare.com/ajax/libs/offline-js/0.7.19/offline.min.js"></script>

    Load the below stylesheet before </head> tag. 1st css is for styling the theme. 2nd css is for language content.

    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/offline-js/0.7.19/themes/offline-theme-slide.min.css"/>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/offline-js/0.7.19/themes/offline-language-english.min.css" />

    Now please this javascript before </body> tag.

     <script>

    Offline.options = {checks: {xhr: {url: 'https://www.masudcomputerbd.com'}}};

    </script>


    You should replace your web link https://www.masudcomputerbd.com

    View Live Demo: Please turn off your wifi connection or internet and wait 2 seconds.



    Tags:check internet connection,check internet connection in javascript,how to check internet connection using javascript,check internet connection status in javascript,internet connection,javascript,toast notification to detect internet connection javascript,check network status using javascript,check if internet connection exists in javascript,how to check network status using javascript,check network status in javascript,detect internet connection

    Newer post Older post
    ads1

    পরিচিতদেরকে জানাতে শেয়ার করুন

    ডোমেইন হোস্টিং সার্ভিস এই লিংকে চাপ দিন

    ওয়েব ডিজাইন সার্ভিস এই লিংকে চাপ দিন

    গ্রাফিক্স ডিজাইন সার্ভিস এই লিংকে চাপ দিন

    ডোমেইন চেকার এই লিংকে চাপ দিন

    আপনার জন্য আরো কিছু পোস্ট

    RELATED ARTICLES

      ads3