I had code with me to check internet connection and also display the online/offline status in label in the time of html page load. but it is not working properly. so please help me to solve the problem.here is the script to check the internet connection.

```
<script type="text/javascript">

    function checkconnection() {

        var status = navigator.onLine;

        if (status) {

            document.getElementById("LblText").value = "ONLINE";

        } else {

            document.getElementById("LblText").value = "OFFLINE";
        }
    }

</script>

```

I am also attaching label syntax below

```
<label id="LblText">NO Text</label>

```

I want to show label text online /offline according to internet connection availability.