Hello everyone
I wonder if there is a way to recognize the visit from user's iphone and automatically adjust web page to fit iPhone screen size?
Hello everyone
I wonder if there is a way to recognize the visit from user's iphone and automatically adjust web page to fit iPhone screen size?
<?php
$isIphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
if ($isIphone == true) { echo 'Code You Want To Execute'; }
?>
I'd say that rather than basing it on the UA, often a screen size query is better. I have used this before in my head
.
<!--[if !IE]>-->
<link type="text/css" rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iPhone.css">
<!--<![endif]-->
You can do User-Agent detection and make changes based on seeing the "iPhone" or "iPod" string, but you can also use a meta tag that is specifically for this purpose.
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
Here's another good resource for information on building an iPhone-ready website.