简体   繁体   English

移动网站无法从Chrome浏览器加载到ipad上

[英]Mobile site fails to load on ipad from chrome safari

I have some code at the front of my index.php file that calls out to a mobile detect php. 我在index.php文件的开头有一些代码,用于调用移动检测php。 It was working fine on iPhone and Android and iPad until one of the more recent ios updates... 8.0 .1 or maybe .2. 在iPhone,Android和iPad上,它一直运行良好,直到有最新的ios更新... 8.0 .1或.2.。 The code seems to try to forward to the flash page. 该代码似乎试图转发到Flash页面。

It still continues to work on Android and iPhone iOS 7. if possible can someone help me figure out what to change in order to get this script to work with the newer versions of iOS. 它仍然可以在Android和iPhone iOS 7上继续运行。如果可能,有人可以帮助我找出要更改的内容,以使此脚本与更新版本的iOS一起使用。

<?php
$tablet_browser = 0;
$mobile_browser = 0;

if (preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera    mini)))/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
$tablet_browser++;
}

if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android|iemobile)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
$mobile_browser++;
}

if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
$mobile_browser++;
}

$mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
$mobile_agents = array(
'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
'newt','noki','palm','pana','pant','phil','play','port','prox',
'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
'wapr','webc','winw','winw','xda ','xda-');

if (in_array($mobile_ua,$mobile_agents)) {
$mobile_browser++;
}

if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'opera mini') > 0) {
$mobile_browser++;
//Check for tablets on opera mini alternative headers
$stock_ua = strtolower(isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])?$_SERVER['HTTP_X_OPERAMINI_PHONE_UA']:(isset($_SERVER['HTTP_DEVICE_STOCK_UA'])?$_SERVER['HTTP_DEVICE_STOCK_UA']:''));
if (preg_match('/(tablet|ipad|playbook)|(android(?!.*mobile))/i', $stock_ua)) {
  $tablet_browser++;
}
}

/*if ($tablet_browser > 0) {
   // do something for tablet devices
  // echo 'is tablet';
}
else if ($mobile_browser > 0) {
   // do something for mobile devices
   echo 'is mobile';
}
else {
   // do something for everything else
  // echo 'is desktop';
}   */

?>

I would suggest using https://github.com/serbanghita/Mobile-Detect/ 我建议使用https://github.com/serbanghita/Mobile-Detect/

Updates are added on the regular, and popularity ensures momentum going forward with future mobile devices. 定期添加更新,其受欢迎程度确保了未来移动设备的发展势头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Safari仅适用于iPad的网站损坏 - Broken site in safari for iPad only .htaccess URL重写在Safari / iPad / iOS上失败 - .htaccess URL rewrite fails on Safari / iPad / iOS 如何检测网站是否正在从IPAD浏览 - How to detect whether a site is browsing from IPAD or not 在chrome和opera上加载网站,但在firefox和safari上部分加载 - Site loading on chrome and opera but partially loading on firefox and safari 从is_mobile排除iPad和平板电脑 - Exclude Ipad and tablets from is_mobile 我的 jQuery IMG 中心脚本在 Chrome 和 Safari 中失败,但在 IE 中有效? - My jQuery IMG center script fails in Chrome and Safari, but works IE? (PHP / JS)Google Maps API 3在IE,FF和iPad(Safari / Chrome)中未获得结果,但在Chrome&M8 Android(本机/ Chrome)中获得结果 - (PHP / JS) Google Maps API 3 not getting results in IE, FF & iPad (Safari / Chrome) but does on Chrome & M8 Android (Native / Chrome) 将视图更改为桌面网站时,移动Google Chrome浏览器会话被破坏 - session destroyed on mobile Google Chrome while changing view to desktop site 如何从移动网站重定向到完整网站? - How to redirect from mobile website to full site? php从移动设备重定向到桌面站点 - php redirect to desktop site from mobile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM