JS判断浏览器的平台

来源:互联网 发布:域名dns未修改 阿里云 编辑:程序博客网 时间:2024/05/28 06:06
 
  1. var str = navigator.platform;    
  2. if(!( str.match(/win32/i) || str.match(/mac/i) || str.match(/linux/i) )) {    
  3. //判断主流电脑操作系统     
  4.     window.location.replace("url");    
  5. else if( str.match(/linux/i) ) {    
  6. //因为Android手机的内核也是Linux,所以要另外判断.     
  7.     var check = navigator.appVersion;    
  8.     if(check.match(/mobile/i) || check.match(/X11/i)) {    
  9. //X11是UC浏览器的平台     
  10.     window.location.replace("url");    
  11.     }    
  12. }    
原创粉丝点击