Chapter 8. JavaScript Mobile

Designing for the Web is about more than content and presentation—users expect websites to be interactive, responding to their choices. Fortunately, although it has some limitations, the JavaScript you use in developing for the mobile web is similar to that used in desktop web development.

We have already talked a bit about the WAP 1.1 standard scripting language, WMLScript. We won’t go any deeper into this obsolete language, but it will not be difficult to learn if you need to do a little scripting with it. The WAP 2.0 standard that brought us XHTML MP and WAP CSS didn’t define any scripting support. This was bad for the first few years, because we could create scripts in WAP 1.0 documents but not in WAP 2.0 ones.

Thankfully, a couple of years after this standard was released, mobile browsers started to add some support for JavaScript (or ECMAScript, to be totally correct). The standards for mobile scripting are more difficult to define than the standards for CSS. The great benefit is that, excepting some bugs, JavaScript can check at runtime whether some feature, object, or API is available, so we can code for different “standards.”

Note

The standard name for JavaScript is ECMAScript, because it is defined by the ECMA (an international, private nonprofit standards organization). There are three well-known dialects on the market: JavaScript (trademark of Sun, licensed now to the Mozilla Foundation), ActionScript (trademark of Adobe), and JScript (trademark ...

Get Programming the Mobile Web now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.