javascript 获取操作系统语言

javascript获取方式:

<script>   
  var s = navigator.systemLanguage;   
  switch(s){   
  case   "zh-cn":   
     document.location.href = 'http://www.google.cn';
  break;   
  case   "zh-tw": 
  document.location.href = 'http://www.google.com.tw';
  case   "zh-hk":  
  document.location.href = 'http://www.google.com.hk';
  break;   
  default:   
  if(s.split("-")[0]=="en"){   
     document.location.href = 'http://www.google.com';  
  }else{   
     document.location.href = 'http://www.google.com';    
  }   
  }   
  </script>

作者:沐雪
文章均系作者原创或翻译,如有错误不妥之处,欢迎各位批评指正。本文版权归作者和博客园共有,如需转载恳请注明。
如果您觉得阅读这篇博客让你有所收获,请点击右下方【推荐】
找一找教程网-随时随地学软件编程 http://www.zyiz.net/

原文地址:https://www.cnblogs.com/puzi0315/p/2658288.html