Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
13 lines (12 sloc) 496 Bytes
<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 statusElem = document.getElementById('status')
setInterval(function () {
statusElem.className = navigator.onLine ? 'online' : 'offline';
statusElem.innerHTML = navigator.onLine ? 'online' : 'offline';
}, 250);
</script>