判断ios还是Android
程序员文章站
2022-03-27 13:07:02
...
<script>
//判断ios还是Android
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if(isAndroid){
}else if(isiOS){
window.location.href = 'http://fms.news.cn/swf/2018_sjxw/10_1_sgq/index.html';
}
var is_mobile = true;
if( navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
|| navigator.userAgent.match(/iPad/i)
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i)
){
is_mobile = true;
}
</script>