手机打开WEB网站自动打开移动版
日期:2015-12-02 / 人气: / 来源:
问:
网站设计有PC版和移动版两种,就是wap网站。
可是手机上面搜索,打开的还是PC版的。
需要做什么处理,或者提交吗,能让在手机打开的就是wap的网站。
解决办法:
在WEB网站加入一段判断的JS即可。
<script src="/style/uaredirect.js" type="text/javascript"></script>
<script type="text/javascript">uaredirect("http://m.dedecms.com");</script>
JS代码为:
function uaredirect(f){try{if(document.getElementById("bdmark")!=null){return}var b=false;if(arguments[1]){var e=window.location.host;var a=window.location.href;if(isSubdomain(arguments[1],e)==1){f=f+"/#m/"+a;b=true}else{if(isSubdomain(arguments[1],e)==2){f=f+"/#m/"+a;b=true}else{f=a;b=false}}}else{b=true}if(b){var c=window.location.hash;if(!c.match("fromapp")){if((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))){location.replace(f)}}}}catch(d){}}function isSubdomain(c,d){this.getdomain=function(f){var e=f.indexOf("://");if(e>0){var h=f.substr(e+3)}else{var h=f}var g=/^www\./;if(g.test(h)){h=h.substr(4)}return h};if(c==d){return 1}else{var c=this.getdomain(c);var b=this.getdomain(d);if(c==b){return 1}else{c=c.replace(".","\\.");var a=new RegExp("\\."+c+"$");if(b.match(a)){return 2}else{return 0}}}}; 作者: 推荐内容 Recommended
相关内容 Related
我们的服务 Our Services我们可以为您提供的服务及我们对服务的态度,服务流程、服务优势、我们眼中的办公环境是怎样的。How are the services that we could provide to you, our attitude toward service, our service process, service advantages and the office environment in our eyes 我们的成功案例 Our Successful Cases我们为您精心挑选的经典案例,去感受不一样的办公环境体验,服务于世界500强的企业为您服务。You can go to review our classic cases that we have picked for you so as to experience different office environments. The enterprise that has serviced world Top 500 enterprises will serve you as well. |