HTML5 and CSS3, Second Edition

(singke) #1
html5_offline/offlinetest.html
window.addEventListener("offline",function(e){
alert("offline");
}, false);

window.addEventListener("online",function(e){
alert("online");
}, false);

Using this approach, we could detect when we lose connectivity, display a
message, and then synchronize everything back up when the connection
becomes active again.

Since synchronizing the data in our app would require some back-end coding,
this is as far as we’ll go in this book. But you have the tools you need to
investigate further.

9.1 The Future


Features like Web Storage and IndexedDB give developers the ability and
flexibility to build applications in the browser that don’t have to be connected
to a web server. Applications like the ones we worked on run on iPad and
Android devices, as well, and when we combine them with the HTML5 manifest
file, we can build offline rich applications using familiar tools instead of pro-
prietary platforms. As additional browsers enable support, developers will be
able to leverage them more, creating applications that run on multiple
platforms and devices, that store data locally, and that can sync up when
connected.

Chapter 9. Saving Data on the Client • 206


Download from Wow! eBook <www.wowebook.com> report erratum • discuss

Free download pdf