Display online offline connection status using JavaScript

Last Reply 8 months ago By dharmendr

Posted 8 months ago

How to displaying online offline connection status in page.

how to display a kind of popup when the network is not connected to the internet.

Posted 8 months ago

Hi arie.keren,

Check this example. The following code executes on every two second and checks if connection is there or not.


<script type="text/javascript">
    window.onload = function () {
        setInterval(function () {
            if (!navigator.onLine) {
                alert("You are not connected to Internet, ensure you're not in airplane mode. \n\nYour internet signal may be week. \n\nPlease connect to internet and try again.");
        }, 2000);