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

Content Adaptation

Content adaptation is a technique for changing the markup delivered by the server depending on the device’s capabilities. The alternative solution is content splitting, where you redirect the user to different folders or domains depending on the device used.

Once we know how to detect capabilities and how to deliver content to the client, we need to decide how we are going to do the content adaptation. Content adaptation has the great advantage that the same source code can be used for all devices; the framework takes care of the adaptation. Therefore, making updates is a one-place modification.

Custom solutions are the most adaptable. My suggestions if you want to develop your own framework are:

  • Create or use a master page or template framework. You will need to define several master pages (e.g., for low-end devices, mid-end devices, smartphones, and perhaps the iPhone).

  • Create standard markup templates for the content of each page. Use headers, paragraphs, unordered lists, and whatever other standard markup you need.

  • Create a different CSS file for each master page.

  • Create a different JavaScript controller file for each master page. Some templates may not have any JavaScript.

  • Create a different JavaScript controller file for the iPhone, using a specific UI library.

  • For the iPhone and other smartphones, change and add behavior using JavaScript in the onload event. If you will create a very different experience for iPhone (and perhaps Android) devices, you will need to ...

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