html5demos/demos/nav-online.html

13 lines
484 B
HTML

<title>navigator.onLine testing</title>
<article>
<p>Current network status: <span id="status">checking...</span></p>
<p>A timer is constantly polling the navigator.onLine property, which is typically switched via File -&gt; Work Offline</p>
</article>
<script>
var status = document.getElementById('status')
setInterval(function () {
status.className = navigator.onLine ? 'online' : 'offline';
status.innerHTML = navigator.onLine ? 'online' : 'offline';
}, 250);
</script>