Browse Source

浏览器缩放

yangc 8 years ago
parent
commit
74d744c7f1
1 changed files with 8 additions and 21 deletions
  1. 8 21
      app.html

+ 8 - 21
app.html

@@ -9,18 +9,6 @@
   <link rel="stylesheet" type="text/css" href="https://at.alicdn.com/t/font_452262_tnqskb835gs98uxr.css">
   {{ HEAD }}
   <script>
-    var reCreateStyle = function() {
-      var style;
-      if(style=document.getElementById("forhtml")){
-        style.parentNode.removeChild(style);
-      }
-      style = document.createElement("style");
-      style.id="forhtml";
-      document.head.appendChild(style);
-
-      var fontSize =  100.00  * (parseFloat(document.documentElement.clientWidth,10)) / 750.00;
-      style.appendChild(document.createTextNode("html{font-size:"+fontSize+"px !important;}"));
-    };
     var _hmt = _hmt || [];
     (function (w, d) {
       if (/(MSIE)|(Trident)/.test(w.navigator.userAgent)) {
@@ -50,17 +38,16 @@
 //        meta2.content = 'no-siteapp'
 //        head.appendChild(meta1)
 //        head.appendChild(meta2)
-//        var docEl = d.documentElement
+        var docEl = d.documentElement
         var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'
         var recalc = function () {
-//          var clientWidth = docEl.clientWidth
-//          if (!clientWidth) return
-//          if (clientWidth >= 750) {
-//            docEl.style.fontSize = '100px'
-//          } else {
-//            docEl.style.fontSize = 100 * (clientWidth / 750) + 'px'
-//          }
-          reCreateStyle();
+          var clientWidth = docEl.clientWidth
+          if (!clientWidth) return
+          if (clientWidth >= 750) {
+            docEl.style.fontSize = '100px'
+          } else {
+            docEl.style.fontSize = 100 * (clientWidth / 750) + 'px'
+          }
         }
 //        recalc()
         if (!d.addEventListener) return