views:

114

answers:

6

My wish is to know how I can program a mobile website, that fit to all mobile phones.

Are there any special approaches to recognize a device and render the code according to it?

Which tools and coding languages are required?

My first thought was to hold the website in XML, which would be parsed depending on the device.

You have to consider old phones, even devices with only wap support.

For example: The mobile website has to recognize Nokia N75 and render/send the code that looks optimal for this device. Same thing with an iPhone or a Motorola Razr.

A: 

One way is to use strict html with very clear semantics and minimum of css tricking. Do only use relative measures (for example em and %). Trust the browsers default values, because they are in one way optimal for every device, more or less.

Johan
+1  A: 

There are all sorts of problems associated with developing mobile websites. Doing it well takes a lot of time and effort, as phones have such varying support of web standards. There are tools that do it for you, such as the Mobile Web Toolkit and Vodafone's PartnerMl. These tend to force you to write your pages using dedicated XML tags which describe a limited set of elements and styles that can be rendered on the page. The phone requests these xml pages, and the server side software intercepts the request, examines the type of phone (the User Agent), and serves back markup appropriate to that phone. The disadvantage of this system is that it is very inflexible; you are limited to the set of XML elements that the tool supplies, rather than the full flexibility of HTML.

If you want to do it yourself, essentially, you have to do the following.

  1. Using server-side code, examine the User Agent in the Http Header. This tells you what kind of phone/browser made the request
  2. Output appropriate markup and CSS for that user agent.

Useful tools are the User Agent Switcher add-in for Firefox. Using this, you can, for instance, visit the BBC's website, pretending to be various devices. You will see that the BBC outputs 3 or 4 versions of its markup, as well as 3 or 4 different versions of the CSS, depending on the user agent.

mobiForge contains useful information. WURFL and DeviceAtlas are databases that allow you to determine the capabilities of the device that has made the request.

You will quickly realise that you will have to keep your design simple, and it's best not to rely on Javascript, as only the most modern phones can handle it well.

darasd
Thanks for this darasd. There are some really helpful approaches in your links.
ChrisBenyamin
A: 

Hi,

Nowadays there isn't exist good tools to do this. A good practice is to respect the different W3C standards about the accessibility (like the WCAG, the XHTML, etc). If you made your web site the most accessible as possible it'll be more adaptable. (independently from device, screen size, with or without screen touch...)

If you want more information you can read one of my article about the web accessibility here if you want: Guideline to move a website on a mobile device.

However you can use some meta tags to allow the web browser of the phone to adjust the content like this for the iPhone:

<meta name="viewport" content="width=device-width">
Yannick L.
Thanks Yannick, but your information is too abstract and actual standard/usual knowledge for web developers. My aim was to discover new ways to consider device-specific needs.
ChrisBenyamin
+1  A: 

XML is the way to go.

From there, you mosey on to parsing out and acting upon the Agent tags in the request.

From there you can choose (assuming the device supports it), having the device render it via XSLT, or you can apply the XSLT on your end and stream down the appropriate markup language for the device.

In the end, you end up with a specific "rendering" per device. Ideally, the more compatible the devices are with normal browsers, the close the final XSLT is to each other. But you'll still likely have a version for each device that you support.

The beauty of this is that you can add devices incrementally, as time and demand permits. And as devices converge, you gain value by being able to converge your renderings. Also, your back end stays the same no matter what.

Finally, it also works great for non-mobile as well.

Yea, it's a burden to support the different devices, but that's just a truth of the marketplace.

Will Hartung
A: 

You might wanna check out WURFL

Paulo Casaretto
+1  A: 

Different mobile has different capabilities (e.g screen size, image support, html support, xhtml support etc.). So it is very important that you know what type of device is trying to access your website and accordingly render required HTML/XHTML supported by the mobile device. So it is very important that you have upto date capability information.

To fetch mobile capabilities use http://www.51degrees.mobi/Products/NETMobileAPI/tabid/86/Default.aspx it is a free ASP.NET mobile api which helps to integrate mobile devices with existing and future web sites. It makes use of WURFL device database which is widely-accepted as the most advanced and up-to-date mobile device database available.

It has add-in for .NET web sites that'll automatically determine if a mobile device is accessing the site and redirect it to mobile specific content. You do not have to update any of your existing asp.net pages for same.

For more details have a look at http://51degrees.mobi/Forum/tabid/92/forumid/3/postid/114/scope/posts/Default.aspx#114

Amit Patel