mirror of
https://github.com/Erreur32/html5demos.git
synced 2024-10-02 22:21:29 +02:00
13 lines
496 B
HTML
13 lines
496 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 -> 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> |