通过JS语句判断WEB网站的访问端是电脑还是手机,以显示不同的页面!

<script type="text/javascript">
<!--
        //平台、设备和操作系统
        var system = {
            win: false,
            mac: false,
            xll: false,
            ipad:false
        };
        //检测平台
        var p = navigator.platform;
        system.win = p.indexOf("Win") == 0;
        system.mac = p.indexOf("Mac") == 0;
        system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
        system.ipad = (navigator.userAgent.match(/iPad/i) != null)?true:false;
        //跳转语句,如果是手机访问就自动跳转到wap.baidu.com页面
        if (system.win || system.mac || system.xll||system.ipad) {

        } else {

            window.location.href = "http://www.jdpatro.com/3g/";
        }
-->
</script>

腾讯网的适配代码:

<script type="text/javascript"> 
if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){
    if(window.location.href.indexOf("?mobile")<0){
        try{
            if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
                window.location.href="http://shipei.qq.com/index.htm";
            }else if(/iPad/i.test(navigator.userAgent)){
            }else{
                window.location.href="http://shipei.qq.com/simple/s/index/"
            }
        }catch(e){}
    }
}
</script>