js检测是否手机访问并跳转

来源:互联网 发布:java decompiler 官网 编辑:程序博客网 时间:2024/04/29 21:45

js检测是否手机访问,如果是手机访问则跳转到指定的url


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://m.example.com/?3G";}} catch (e) {}}}


0 0