Introduction
In today's development world, we are creating web applications which can run in both modes (i.e. online and offline mode) using HTML5 capabilities.
Below is the sample code to detect current mode using JavaScript:
<script>
window.addEventListener('load', function (e) {
}, false);
window.addEventListener('online', function (e) {
alert("you are online"); }, false);
window.addEventListener('offline', function (e) {
alert("you are offline");}, false);
</script>
Use the above code and play with online /offline mode. :)