不同设备(ipad、iphone、PC、android、androidpad)访问同一页面跳转

<html>
<head>
<title>
不同设备跳转
</title>
 <script type="text/javascript">   
    window.onload=function(){
        var sUserAgent = navigator.userAgent.toLowerCase(); 
        var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";  
        var bIsIphoneOs = sUserAgent.match(/iphone/i) == "iphone";  
        var bIsAndroid = ((sUserAgent.match(/android/i) == "android")&&(sUserAgent.match(/build/i) == null))||(sUserAgent.match(/mi/i)=="mi")||(sUserAgent.match(/x11/i)=="x11");
        var bIsAndroidpad = (sUserAgent.match(/android/i) == "android")&&(sUserAgent.match(/build/i) == "build")&&(sUserAgent.match(/mi/i)==null);;         
        if (bIsIpad) 
        {  
            window.location.href="http://www.baidu.com";
             
        } 
        else if(bIsIphoneOs) {  
            window.location.href="http://www.tianya.cn";
    
        }
        else if(bIsAndroid) {  
            window.location.href="http://www.pengyou.com";

        }
        else if(bIsAndroidpad) {  
            window.location.href="http://www.hao123.com";
 
        } 
    }

 </script>
</head>

<body>
 不同设备跳转说
</body>
</html>
原文地址:https://www.cnblogs.com/luojie/p/3118649.html