html+js实现判断不同设备跳转不同页面
原创
©著作权归作者所有:来自51CTO博客作者于飞工作室的原创作品,请联系作者获取转载授权,否则将追究法律责任
简介
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>