| <script type="text/javascript"> try { var urlhash = window.location.hash; if (!urlhash.match("fromapp")) { if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i))) { var docsUrl = "http://" + window.location.host + "/wap"; window.location= docsUrl } } } catch(err) {} </script> |
或
| <script type="text/javascript"> try{ if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { window.location.href="/wap"; } }catch(e){} </script> |
或多重判断:
| <script type="text/javascript"> try{ if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { window.location.href="/wap"; //判断访问环境是Android|webOS|iPhone|iPod|BlackBerry就访问/wap } else if(/iPad/i.test(navigator.userAgent)){ window.location.href="/ipad"; //判断访问环境是iPad平板就访问/ipad } else{ window.location.href="/pc"; //如果以上都不是,则访问/pc } }catch(e){} </script> |
或者是:
| <script type="text/javascript"> <!-- //平台、设备和操作系统 var system = { win: false, mac: false, xll: false, ipad: false }; //检测平台 var p = navigator.platform; system.win = p.indexOf("Win") == 0; system.mac = p.indexOf("Mac") == 0; system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); system.ipad = (navigator.userAgent.match(/iPad/i) != null) ? true : false; //跳转语句电脑或平板访问就自动跳转到/PC if (system.win || system.mac || system.xll || system.ipad) { window.location.href="/pc"; } //非以上跳转到/wap,如果代码放在手机端网站,下面的代码可以去掉 else{ window.location.href="/wap"; } </script> |
文章来源:
网络小编D
版权声明:
本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,请联系本站立刻删除。
