挪动端兼容

<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>

    原文作者:Mrlijie
    原文地址: https://segmentfault.com/a/1190000017440465
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞