Display online offline connection status using JavaScript

Last Reply one month ago By dharmendr

Posted one month 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 one month ago

Hi arie.keren,

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

HTML

<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);
    }
</script>

Demo