移動端相容

Mrlijie發表於2019-02-16

<head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>首頁</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta name="HandheldFriendly" content="true" />
    <meta name="MobileOptimized" content="width" />
    <meta id="viewport" content="width=device-width, user-scalable=no,initial-scale=1" name="viewport" />
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no" name="format-detection" />
    <!--移動端版本相容 -->
    <script type="text/javascript">
        var phoneW =  parseInt(window.screen.width),phoneScale = phoneW/640 ,ua = navigator.userAgent;
        if (/Android (d+.d+)/.test(ua)){
            var version = parseFloat(RegExp.$1);
            if(version>2.3){document.write(`<meta name="viewport" content="width=640, initial-scale=`+phoneScale+`, minimum-scale = `+phoneScale+`, maximum-scale = `+phoneScale+`, target-densitydpi=device-dpi">`);
            }else{document.write(`<meta name="viewport" content="width=640, target-densitydpi=device-dpi">`);}
        } else {document.write(`<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">`);}
    </script>
    <link href="css/all.css" type="text/css" rel="stylesheet"/>
    <link href="css/swiper.min.css" type="text/css" rel="stylesheet"/>
    <link href="css/index.css" type="text/css" rel="stylesheet"/>
    <script src="js/jquery-3.3.1.min.js"></script>
    <script src="js/swiper.min.js"></script>

</head>

相關文章