Switched demo to use addEvent method to test in older versions of IE

This commit is contained in:
Remy Sharp 2010-03-20 19:20:28 +00:00
parent 8c773e8db2
commit caf1b38f0c
1 changed files with 23 additions and 23 deletions

View File

@ -26,29 +26,29 @@ li::before {
<p>Note that the test shows that <code>window.ononline</code> and <code>window.onoffline</code> doesn't work (which I thought I had read in the specs somewhere...).</p>
</article>
<script>
function update(online) {
document.getElementById('viabody').innerHTML = navigator.onLine ? 'Online' : 'Offline';
}
function update(online) {
document.getElementById('viabody').innerHTML = navigator.onLine ? 'Online' : 'Offline';
}
window.addEventListener('online', function () {
document.getElementById('vialistener').innerHTML = 'Online';
}, false);
window.addEventListener('offline', function () {
document.getElementById('vialistener').innerHTML = 'Offline';
}, false);
window.ononline = function () {
document.getElementById('viaon').innerHTML = 'Online';
};
window.onoffline = function () {
document.getElementById('viaon').innerHTML = 'Offline';
};
document.body.onOnline = update;
document.body.onOffline = update;
document.body.onload = update;
addEvent(window, 'online', function () {
document.getElementById('vialistener').innerHTML = 'Online';
});
addEvent(window, 'offline', function () {
document.getElementById('vialistener').innerHTML = 'Offline';
});
window.ononline = function () {
document.getElementById('viaon').innerHTML = 'Online';
};
window.onoffline = function () {
document.getElementById('viaon').innerHTML = 'Offline';
};
document.body.onOnline = update;
document.body.onOffline = update;
document.body.onload = update;
</script>