mirror of
https://github.com/Erreur32/html5demos.git
synced 2024-10-01 15:11:35 +02:00
19 lines
588 B
HTML
19 lines
588 B
HTML
<title>Online connectivity monitoring</title>
|
|
<article>
|
|
<p>Current network status: <span id="status">checking...</span></p>
|
|
<ol id="state"></ol>
|
|
</article>
|
|
<script>
|
|
var status = document.getElementById('status'),
|
|
state = document.getElementById('state');
|
|
|
|
function online(event) {
|
|
status.className = navigator.onLine ? 'online' : 'offline';
|
|
status.innerHTML = navigator.onLine ? 'online' : 'offline';
|
|
state.innerHTML += '<li>New event: ' + event.type + '</li>';
|
|
}
|
|
|
|
addEvent(window, 'online', online);
|
|
addEvent(window, 'offline', online);
|
|
online({ type: 'ready' });
|
|
</script> |