HTML and CSS Reference
In-Depth Information
7
Chapter
JavaScript for Mobile
JavaScript for mobile has come quite a long way since the dawn of the first
consumer WAP mobile phone, the Nokia 7110, in 1999. From having absolutely
no support to having full support and more in just over 10 years, JavaScript has
made our mobile web experience much more interactive, interesting, and
fulfilling.
The problem today is, with so much JavaScript support, how do we leverage it
to our advantage, make it unobtrusive, and provide a good and smooth
experience for our users?
This chapter will guide you through how to integrate JavaScript into your
projects, using the different types of libraries available to make it easier for you
to produce mobile web applications that should work on any platform. You will
also learn about the new HTML5 JavaScript APIs (such as geolocation), storage,
and how to leverage it to draw vector-based graphics for Android using the
HTML5 Canvas element.
Object-Oriented JavaScript
JavaScript is a fantastic language for handling and processing user interaction
in mobile web sites. In much the same way as you write JavaScript for the
desktop web, you can also make use of the same design patterns and method
of writing for mobile. You can write JavaScript in one of two ways. One of these
methods is procedural, as shown in the following code.
function sayHelloWorld(foo){
alert(foo);
}
 
Search WWH ::




Custom Search