首页 > 代码库 > JS判断请求来自Android手机还是iPhone手机

JS判断请求来自Android手机还是iPhone手机

<script type="text/javascript">var browser = {versions: function () {var u = navigator.userAgent, app = navigator.appVersion;return { //移动终端浏览器版本信息ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端android: u.indexOf(‘Android‘) > -1 || u.indexOf(‘Linux‘) > -1, //android终端或uc浏览器iPhone: u.indexOf(‘iPhone‘) > -1, //是否为iPhone或者QQHD浏览器iPad: u.indexOf(‘iPad‘) > -1, //是否iPad};}(),}if (browser.versions.iPhone || browser.versions.iPad || browser.versions.ios) {window.location.href = "http://www.asiayak.cn";}if (browser.versions.android) {window.location.href = "http://www.qq.com";}