当前位置:   article > 正文

js判断接入设备_js能否获取电脑插入的设备

js能否获取电脑插入的设备
  1. <script type="text/javascript">
  2. function browserRedirect() {
  3. var sUserAgent = navigator.userAgent.toLowerCase();
  4. var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
  5. var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
  6. var bIsMidp = sUserAgent.match(/midp/i) == "midp";
  7. var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
  8. var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
  9. var bIsAndroid = sUserAgent.match(/android/i) == "android";
  10. var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
  11. var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
  12. document.writeln("您的浏览设备为:");
  13. if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
  14. document.writeln("phone");
  15. } else {
  16. document.writeln("pc");
  17. }
  18. }
  19. browserRedirect();
  20. </script>



  1. <script type="text/javascript">
  2. // borwserRedirect
  3. (function browserRedirect(){
  4. var sUserAgent = navigator.userAgent.toLowerCase();
  5. var bIsIpad = sUserAgent.match(/ipad/i) == 'ipad';
  6. var bIsIphone = sUserAgent.match(/iphone os/i) == 'iphone os';
  7. var bIsMidp = sUserAgent.match(/midp/i) == 'midp';
  8. var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == 'rv:1.2.3.4';
  9. var bIsUc = sUserAgent.match(/ucweb/i) == 'web';
  10. var bIsCE = sUserAgent.match(/windows ce/i) == 'windows ce';
  11. var bIsWM = sUserAgent.match(/windows mobile/i) == 'windows mobile';
  12. if(bIsIpad || bIsIphone || bIsMidp || bIsUc7 || bIsUc || bIsCE || bIsWM){
  13. window.location.href = 'http://www.163.com/';
  14. }else{
  15. window.location.href = 'http://www.baidu.com/';
  16. }
  17. })();
  18. </script>


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/321038
推荐阅读
相关标签
  

闽ICP备14008679号