Windows Mobile 6: Ajax and Windows Mobile 6

Ajax – the design model that aims to give web pages the look, feel and usability of applications – is all the rage. Of course, experienced web designs will sigh and mention that Ajax-like techniques have been used for years before it became known as “Ajax” and got all trendy, but that’s not the point.

The point is that Ajax applications are supported by the Internet Explorer Mobile web browser that ships with Windows Mobile devices. Better yet, Windows Mobile 6 comes with an updated version of Internet Explorer Mobile that supports more of the DOM and is therefore an even more attractive Ajax platform.

Think about it: what’s not to like about a way of delivering applications that requires no download or installation, can be updated any time, provides up-to-the-second information over-the-air, doesn’t take up lots of memory…? it’s a perfect way to deliver many kinds of applications to Pocket PCs and Smartphones. Oops, I mean, Windows Mobile 6 Professional and Windows Mobile 6 Standard devices.

Anyway, I’ve been cooped up in my office playing with Ajax, and whilst it’s truthful to say that Internet Explorer Mobile supports Ajax-style applications, it’s perhaps more honest to say that Ajax-style applications are definitely supported, but you may have to tweak them a little bit to get them to work.

By far the biggest issue is something that has been fixed in Windows Mobile 6: support for the getElementById method. This method is used all the time in Ajax samples, and if you were scratching your head wondering why your application wouldn’t work on a mobile device, but worked on the desktop, there’s a good chance this is why. There’s a perfectly simple work around (use the element’s ID name directly), but the good news is that Windows Mobile 6 supports this method from now on. Unless you are certain your application will only be accessed by Windows Mobile 6 devices, this is something you will need to take into consideration.

Some other issues I came across were to do with directly accessing a Submit control in a form. Turns out the sample code I was looking at directly accessed the collection associated with the control, but in the mobile world, that collection is read only. Again, the work around is minor (ok, it took me two days to work out, but I’m still kinda new to this), and once you figure it out, everything works fine.

I turned my learning experience into a sample that you can download and use directly from the Windows Mobile Developer Wiki. You’ll need to put the files on your own web server to access them, but even if you don’t do this, you’ll see how easy it is to develop applications using this approach. I've not spent any time on the appearance of this application: I'll leave that as an exercise for the reader.

Please feel free to send me comments on improving it, or if you are having issues with your own Ajax experiments.

Link to Ajax Sample