天天看點

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';

  default:   

  if(s.split("-")[0]=="en"){   

     document.location.href = 'http://www.google.com';  

  }else{   

     document.location.href = 'http://www.google.com';    

  }   

  </script>

繼續閱讀