手機打開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.dede58.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. |