五分钟内反应回复,平均十分钟解决任何IT技术问题,按难度跟工作量收费!

手机自适应代码,兼容所有游览器

admin |浏览554次
收藏|2017/06/23 14:15

<script type="text/javascript">
function browserRedirect() {
    var sUserAgent = navigator.userAgent.toLowerCase();
    //var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
    var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
    var bIsMidp = sUserAgent.match(/midp/i) == "midp";
    var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
    var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
    var bIsAndroid = sUserAgent.match(/android/i) == "android";
    var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
    var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
    if (( bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) )
    {
        /* $(document).ready(function(){
            $("#ceshizh").html("web");
        }) *///手机页面
        document.write("<link href='/skin/new/css/weblib.min.css?version=20150420'  type='text/css' rel='stylesheet' />");
        document.write("<link href='/skin/new/css/webindex.css' type='text/css' rel='stylesheet' />");
    }
    else
    {
        //document.write("web");
        //alert("ok");
        
        /* $(document).ready(function(){
            $("#ceshizh").html("web");
        }) */
        document.write("<link href='/skin/new/css/lib.min.css?version=20150420'  type='text/css' rel='stylesheet' />");
        document.write("<link href='/skin/new/css/index.css' type='text/css' rel='stylesheet' />");
    }
}
browserRedirect();
</script>

+1
 加载中...