2010-03-04 13:07:09 +01:00
|
|
|
<title>Online connectivity monitoring</title>
|
|
|
|
<article>
|
|
|
|
<p>Current network status: <span id="status">checking...</span></p>
|
2010-03-04 16:09:30 +01:00
|
|
|
<ol id="state"></ol>
|
2010-03-04 13:07:09 +01:00
|
|
|
</article>
|
|
|
|
<script>
|
2010-03-04 16:09:30 +01:00
|
|
|
var status = document.getElementById('status'),
|
|
|
|
state = document.getElementById('state');
|
2010-03-04 13:07:09 +01:00
|
|
|
|
2010-03-04 16:09:30 +01:00
|
|
|
function online(event) {
|
|
|
|
status.className = navigator.onLine ? 'online' : 'offline';
|
|
|
|
status.innerHTML = navigator.onLine ? 'online' : 'offline';
|
|
|
|
state.innerHTML += '<li>New event: ' + event.type + '</li>';
|
|
|
|
}
|
2010-03-04 13:07:09 +01:00
|
|
|
|
2010-03-04 16:09:30 +01:00
|
|
|
addEvent(window, 'online', online);
|
|
|
|
addEvent(window, 'offline', online);
|
|
|
|
online({ type: 'ready' });
|
2010-03-04 13:07:09 +01:00
|
|
|
</script>
|