To detect iPhone users on your sites, you can do so client-side or server-side.
Client-side (javascript):
if (navigator.userAgent.indexOf('iPhone') != -1) {
/* iPhone user */
}
Server-side (example is PHP):
if (stristr($_SERVER['HTTP_USER_AGENT'],'iPhone')) {
/* iPhone user */
}
For sites that use an MVC coding pattern where the programming logic code is separate from the template, the following example is useful:
if (stristr($_SERVER['HTTP_USER_AGENT'],'iPhone')) {
$template = 'home/iphone.html';
} else {
$template = 'home/index.html';
}
Category |
Font name |
Description |
Example |