帝国cms判断手机用户跳转
发布:smiling 来源: PHP粉丝网 添加日期:2014-11-22 11:11:49 浏览: 评论:0
帝国cms判断为手机用户直接跳转到手机版访问地址:
- <script type="text/javascript">
- 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){
- window.location.href = "你的WAP地址";
- }//开源软件:phpfensi.com
- }
- if(bIsIphoneOs || bIsAndroid){
- var sUrl = location.href;
- if(!bForcepc){
- window.location.href = "你的WAP地址";
- }
- }
- if(bIsMidp||bIsUc7||bIsUc||bIsCE||bIsWM){
- var sUrl = location.href;
- if(!bForcepc){
- window.location.href = "你的WAP地址";
- }
- }
- }
- 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";
- }
- }
- fBrowserRedirect();
- </script>
Tags: 帝国cms用户手机 帝国cms跳转
- 上一篇:帝国CMS-robots.txt文件使用教程
- 下一篇:帝国CMS统计留言数量
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)