Identifying iPhone browser

PHP:

  $iphone = strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone');
  $ipod = strpos($_SERVER['HTTP_USER_AGENT'], 'iPod');
  if($iphone || $ipod){
    header('Location: http://m.example.com/');
  }

JavaScript:

if((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1)){
  document.location = "http://m.example.com/";
}

ที่มา: http://eugen.io/2009/12/setting-up-your-web-site-to-run-on-iphone-browser/

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz