Is there a way to recognize a iphone user’s visit and automatically adjust the web page to fit the iPhone screen size?

I wonder if there is a way to recognize an iphone user’s visit and automatically adjust the web page to fit the iPhone screen size?

+3
source share
4 answers
<?php
$isIphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
if ($isIphone == true)  { echo 'Code You Want To Execute'; }
?>
+3
source

I would say that instead of basing it on UA, often asking for screen size is better. I used it before in mine head.

<!--[if !IE]>-->
<link type="text/css" rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iPhone.css">
<!--<![endif]-->
+2
source

, . User-Agent HTTP- - .

+1

You can perform User-Agent discovery and make changes depending on the look of the iPhone or iPod string, but you can also use the meta tag specifically for this purpose .

<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"> 

Here is another good resource for information on creating an iPhone-ready website .

+1
source

Source: https://habr.com/ru/post/1736111/


All Articles