Skip to content

Commit bfb1728

Browse files
committed
增加可读性
1 parent 0b8a614 commit bfb1728

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

mobileAdaptive/03/index.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@
66
<title>zoom放大</title>
77
<link rel="stylesheet" href="style.css"/>
88
<style id="_zoom"></style>
9+
<script>
10+
var deviceWidth = 0, // 设备宽度
11+
zoomScale = 0, // 缩放比例
12+
elHead = 0, // head节点
13+
elZoomStyle = document.getElementById("zoomScale"), // zoom样式节点
14+
scaleChange = function () { // 设备比例发生改变时触发函数
15+
deviceWidth = document.documentElement.clientWidth || document.body.clientWidth;
16+
zoomScale = deviceWidth / 640;
17+
elZoomStyle.innerHTML = ".zoom {zoom:" + zoomScale + ";-webkit-text-size-adjust:auto!important;}";
18+
};
19+
elZoomStyle || (elHead = document.getElementsByTagName("head")[0], elZoomStyle = document.createElement("style"), elHead.appendChild(elZoomStyle));
20+
scaleChange();
21+
window.addEventListener("resize", scaleChange, false);
22+
</script>
923
</head>
1024
<body class="zoom">
1125
<div class="viewport">
@@ -26,19 +40,5 @@
2640
</div>
2741
</div>
2842
</div>
29-
<script>
30-
(function(){
31-
var _w,_zoom,_hd, _orientationChange,_doc = document,__style = _doc.getElementById("_zoom");
32-
__style || (_hd = _doc.getElementsByTagName("head")[0],__style=_doc.createElement("style"),_hd.appendChild(_style));
33-
_orientationChange = function(){
34-
_w = _doc.documentElement.clientWidth || _doc.body.clientWidth;
35-
_zoom = _w / 640;
36-
__style.innerHTML = ".zoom {zoom:" + _zoom + ";-webkit-text-size-adjust:auto!important;}";
37-
};
38-
__style.setAttribute("zoom",_zoom);
39-
_orientationChange();
40-
window.addEventListener("resize",_orientationChange,false);
41-
})();
42-
</script>
4343
</body>
4444
</html>

0 commit comments

Comments
 (0)