JS判断浏览器的平台

来源:互联网 发布:python opencv otsu 编辑:程序博客网 时间:2024/05/13 12:33
var str = navigator.platform;  if(!( str.match(/win32/i) || str.match(/mac/i) || str.match(/linux/i) )) {  //判断主流电脑操作系统      window.location.replace("url");  } else if( str.match(/linux/i) ) {  //因为Android手机的内核也是Linux,所以要另外判断.      var check = navigator.appVersion;      if(check.match(/mobile/i) || check.match(/X11/i)) {  //X11是UC浏览器的平台      window.location.replace("url");      }  }  


navigator对象的资料:http://www.w3school.com.cn/htmldom/dom_obj_navigator.asp


原创粉丝点击