O'Reilly logo

Programming the Mobile Web by Maximiliano Firtman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Coding JavaScript for Mobile Browsers

First of all, let’s see what is happening with basic JavaScript compatibility (variables, functions and basic alert functionality) with mobile browsers. Table 8-1 illustrates the current levels of support on the different platforms.

Table 8-1. JavaScript support compatibility table

Browser/platform

JavaScript support

Safari

Yes

Android browser

Yes

Symbian/S60

Yes

Nokia Series 40

Yes

webOS

Yes

BlackBerry

Yes from 3.8

Can be disabled by the user or the company; in that case, noscript is executed

NetFront

Yes

Openwave (Myriad)

Not available in Openwave; yes in Myriad Browser V7

Internet Explorer

Yes

Motorola Internet Browser

Yes

Opera Mobile

Yes

Opera Mini

Yes, but everything after the onload script will be executed on the server, generating a postback

Note

As Openwave does not support JavaScript and Myriad 7 is not commonly found on mobile devices today (making testing difficult), Openwave/Myriad will be left out of the following JavaScript-related tables.

We need to pay special attention to proxied browsers, like Opera Mini. Remember that these browsers render our websites on their servers and send compressed and compiled content to the clients. The clients aren’t really browsers capable of rendering an XHTML file or JavaScript code.

Note

For old non-JavaScript mobile browsers or for browsers with JavaScript disabled, we can use the noscript tag. Only those browsers will display its content.

When we talk about mobile JavaScript, we are talking about the same code you already ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required