17. Detecting Mobile Devices

Mobile websites are often developed separately from primary websites (those intended to be viewed on a desktop or laptop), although they may use much of the same content. To make sure your website is tailored for mobile devices, you’ll want to detect when a mobile device visits the site and then redirect the device to markup made especially for mobile. You may also want to deliver a website layout and content based on a specific mobile device. In this chapter, you’ll learn how to do both. Let’s begin by learning how to detect when a mobile device accesses your website.

Using PHP

Since PHP is one of the most popular scripting languages on the web, let’s look at a PHP function that performs mobile detection across a ...

Get jQuery Mobile: Develop and Design 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.