zoukankan      html  css  js  c++  java
  • 移动端游览器自适应代码

    移动端游览器自适应调整

     1 <script type="text/javascript">// <![CDATA[
     2 var jsVer = 28;
     3 
     4         var phoneWidth = parseInt(window.screen.width);
     5 
     6         var phoneScale = phoneWidth / 640;
     7 
     8         var ua = navigator.userAgent;
     9 
    10         if (/Android (d+.d+)/.test(ua)) {
    11 
    12             var version = parseFloat(RegExp.$1);
    13 
    14             // andriod 2.3
    15 
    16             if (version > 2.3) {
    17 
    18                 document.write('<meta name="viewport" content="width=640, minimum-scale = ' + phoneScale + ', maximum-scale = ' + phoneScale + ', target-densitydpi=device-dpi">');
    19 
    20                 // andriod 2.3以上
    21 
    22             } else {
    23 
    24                 document.write('<meta name="viewport" content="width=640, target-densitydpi=device-dpi">');
    25 
    26             }
    27 
    28             // 其他系统
    29 
    30         } else {
    31 
    32             document.write('<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">');
    33 
    34         }
    35 // ]]></script>
    View Code
  • 相关阅读:
    团队项目-BUG挖掘
    评论任务
    4-14结对-复利计算
    做汉堡-结对
    复利计算--结对
    input上传按钮的优化
    avalon.js与 ajax使用的一个错误实例
    去除list集合中重复项的几种方法
    mvc学习记录
    常用js正则
  • 原文地址:https://www.cnblogs.com/itslives-com/p/metaphone.html
Copyright © 2011-2022 走看看