gistfile1.txt (function (doc, win) { var docEl = doc.documentElement, resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',/* recalc函数实现了自适应屏幕的功能,不需要改动 */recalc = function () { var
(function (doc, win) { var docEl = doc.documentElement, resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', /* recalc函数实现了自适应屏幕的功能,不需要改动 */ recalc = function () { var clientWidth = docEl.clientWidth, scale = 1 / window.devicePixelRatio, uiWidth = 750; if (!clientWidth) return; document.querySelector('meta[name="viewport"]').setAttribute('content', 'width=device-width, initial-scale='+ scale +', maximum-scale='+ scale +', minimum-scale='+ scale +', user-scalable = no'); docEl.style.fontSize = 100 * (clientWidth / uiWidth) + 'px'; }, /* 业务逻辑在init函数里,在此添加业务逻辑 */ init = function () { var getDom = function (id) { return doc.getElementById(id) }; getDom('forgetPassword').addEventListener('click', function(){ getDom('mainBox').className += ' find'; }, false); }; if (!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false); doc.addEventListener('DOMContentLoaded', recalc, false); doc.addEventListener('DOMContentLoaded', init, false); })(document, window);