js检测客户端类型并跳转
来源:互联网 发布:java的日志框架 编辑:程序博客网 时间:2024/04/30 10:44
var bForcepc = fGetQuery("dv") =="pc"; function fBrowserRedirect(){ var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) =="ipad"; var bIsIphoneOs = sUserAgent.match(/iphone os/i) =="iphone os"; var bIsMidp = sUserAgent.match(/midp/i) =="midp"; var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) =="rv:1.2.3.4"; var bIsUc = sUserAgent.match(/ucweb/i) =="ucweb"; var bIsAndroid = sUserAgent.match(/android/i) =="android"; var bIsCE = sUserAgent.match(/windows ce/i) =="windows ce"; var bIsWM = sUserAgent.match(/windows mobile/i) =="windows mobile"; if(bIsIpad){ var sUrl = location.href; if(!bForcepc){ return true; } } if(bIsIphoneOs || bIsAndroid){ var sUrl = location.href; if(!bForcepc){ return true; } } if(bIsMidp||bIsUc7||bIsUc||bIsCE||bIsWM){ var sUrl = location.href; if(!bForcepc){ return true; } } return false; } function fGetQuery(name){//获取参数值 var sUrl = window.location.search.substr(1); var r = sUrl.match(new RegExp("(^|&)"+ name +"=([^&]*)(&|$)")); return(r ==null?null: unescape(r[2])); } function fShowVerBlock(){ if(bForcepc){ document.getElementById("dv_block").style.display ="block"; } else{ document.getElementById("ad_block").style.display ="block"; } } if(fBrowserRedirect()){ if (window.location.host=='www.xxx.com') { window.location.href='http://m.xxx.com'+window.location.href.substr(window.location.href.indexOf(window.location.host)+window.location.host.length,window.location.href.length); }; }else{ if (window.location.host=='m.xxx.com') { window.location.href='http://www.xxx.com'+window.location.href.substr(window.location.href.indexOf(window.location.host)+window.location.host.length,window.location.href.length); };}
0 0
- js检测客户端类型并跳转
- js检测是否手机访问并跳转
- ASP检测手机客户端并跳转到相应页面
- js客户端检测
- js客户端检测
- JS 客户端检测
- js--客户端检测
- js--客户端检测
- JS 客户端检测
- JS检测客户端
- Js客户端检测
- js 类型检测
- js数组类型检测
- js类型检测
- JS类型检测
- js的类型检测
- js 类型检测
- js检测类型
- js取小数点后两位 方法总结
- FTP上传文件
- ImageView的ScaleType属性浅析
- 多线程并发 ——BlockingQueue详解
- 解决svn意外终止后,死锁现象
- js检测客户端类型并跳转
- K-SVD算法简介
- Android:混淆文件proguard.cfg详解
- iOS中的崩溃类型
- 程序猿的简历一
- 使用Qt / C + +通过JNI调用Java代码
- spring 之自动代理
- 省市区 【构建对象】转换成json
- Scrapy研究探索2