javascript判断手机/平板电脑浏览器
javascript判断手机/平板电脑浏览器

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://m.guzheng.cn/";
            }else if(/iPad/i.test(navigator.userAgent)){
              window.location.href="http://www.guzheng.cn/";
            }else{
              //window.location.href="http://m.guzheng.cn/";
            }
        }catch(e)
		{

		}
    }
}
else
{
 //window.location.href="http://www.guzheng.cn/";
}

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注