HTML and CSS Reference
In-Depth Information
window.setInterval(
function () { log('onLine: ' + navigator.onLine); },
10000
);
window.addEventListener('online',
function () { log('online event fired'); } ,
false
);
window.addEventListener('offline',
function () { log('offline event fired'); } ,
false
);
The log function writes a message on
the screen so you can see what's going
on. The full listing is in ch06/offline-
example/offline-events.html.
In the screenshot, the local web server
was started and the page loaded. After
a short time, the local web server was
stopped. As you can see, it made abso-
lutely no difference to the output in the
browser.
The reason is that these events and
properties aren't designed to track
what's going on with the network con-
nection or the availability of the
remote server. Instead, they're
plumbed directly into a menu item in
the browser UI: the Work Offline
entry, which is usually on the File
menu.
 
Search WWH ::




Custom Search