简介

html+js实现判断不同设备跳转不同页面的方法

js代码

<script type="text/javascript">  
var userAgent = navigator.userAgent.toLowerCase();
var platform;
if(userAgent == null || userAgent == ''){
platform = 'WEB' ;
}else{
if(userAgent.indexOf("android") != -1 ){
platform = 'ANDROID';
location.href = "http://2bbt.com/";
}else if(userAgent.indexOf("ios") != -1 || userAgent.indexOf("iphone") != -1 || userAgent.indexOf("ipad") != -1){
platform = 'IOS';
location.href = "http://2bbt.com/";
}else if(userAgent.indexOf("windows phone") != -1 ){
platform = 'WP';
location.href = "http://2bbt.com/";
}else{
platform = 'WEB' ;
location.href = "http://2bbt.com/pc";
}
}
</script>