通过Javascript / jQuery的检测Android手机 [英] Detect Android phone via Javascript / jQuery

查看:176
本文介绍了通过Javascript / jQuery的检测Android手机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何将检测到该设备中使用的是一个Android的移动网站?

How would i detect that the device in use is an Android for a mobile website?

我需要办理一定的CSS属性到Android平台。

I need to apply certain css attributes to the Android platform.

感谢

推荐答案

看看是: http://davidwalsh.name/detect -Android

JavaScript的:

JavaScript:

var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
if(isAndroid) {
  // Do something!
  // Redirect to Android-site?
  window.location = 'http://android.davidwalsh.name';
}

PHP:

$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
if(stripos($ua,'android') !== false) { // && stripos($ua,'mobile') !== false) {
  header('Location: http://android.davidwalsh.name');
  exit();
}

这篇关于通过Javascript / jQuery的检测Android手机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆