网上很多代码。。。试了很多,不管用,其中一个有用,记录下来!!
<script type="text/javascript">
if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){
if(window.location.href.indexOf("?mobile")<0){
try{
if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
window.location.href="http://www.bqkeji.com/mobile";//手机端网址
}else if(/iPad/i.test(navigator.userAgent)){
}else{
window.location.href="http://www.bqkeji.com";//pc端网址
}
}catch(e){}
}
}
</script>
只需要写在pc端的index页面的head 里即可。
本文提供了一段用于判断用户设备类型并实现从PC端到手机端网站自动跳转的JavaScript代码。该代码适用于大多数现代浏览器,并能够有效区分不同类型的移动设备。

155

被折叠的 条评论
为什么被折叠?



