Mobile JavaScript Application
Development
Adrian Kosmaczewski
Beijing
•
Cambridge
•
Farnham
•
Köln
•
Sebastopol
•
Tokyo
Downloa d f r o m W o w ! e B o o k < w w w.woweb o o k . c o m >
Mobile JavaScript Application Development
by Adrian Kosmaczewski
Copyright © 2012 Adrian Kosmaczewski. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (http://my.safaribooksonline.com). For more information, contact our
corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com.
Editor: Simon St. Laurent
Production Editor: Melanie Yarbrough
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrator: Robert Romano
Revision History for the First Edition:
2012-06-14 First release
See http://oreilly.com/catalog/errata.csp?isbn=9781449327859 for release details.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. Mobile JavaScript Application Development, the cover image of a dacelo rufous-
collard kingfisher, and related trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.
ISBN: 978-1-449-32785-9
[LSI]
1339700863
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
1. HTML5 for Mobile Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
A Bit of History 1
Declarations and Meta Tags 2
A Minimal HTML5 Document 2
Doctype 2
Charset 2
JavaScript and Stylesheets 3
New and Obsolete Elements 3
HTML5 Applications 3
Add Web Apps to Home Screen in iOS 4
Add Web Apps to Home Screen in Android 5
Metadata for HTML5 Applications 5
HTML5 Application Cache 8
Manifest Files in Apache 11
Manifest Files with PHP 11
Manifest Files in IIS 11
Manifest Files in .NET 12
Debugging Manifest Files 13
Testing for HTML5 Features 13
Geolocation 14
Device Orientation 15
Device Motion 15
Network Connectivity 17
Canvas 18
CSS3 Animations and Transitions 20
Transitions 20
Animations 22
Final Considerations 23
Client-Side Storage 24
SQL Storage 25
iii