电话
13363039260
<script type="text/javascript"> | |
// 根据屏幕大小自动调整document的字体大小 | |
(function (doc, win) { | |
var docEl = doc.documentElement; | |
var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'; | |
var scale = 1; | |
// if([320,360,375,414,640].indexOf(docEl.clientWidth) >= 0) return; | |
var recalc = function () { | |
var width = docEl.clientWidth; | |
if(width >= 640){ | |
docEl.style.fontSize = '32px'; | |
document.getElementsByTagName('html')[0].style.fontSize = '32px'; | |
}else{ | |
docEl.style.fontSize = width / 20 * scale + 'px'; | |
document.getElementsByTagName('html')[0].style.fontSize = width / 20 * scale + 'px'; | |
} | |
}; | |
recalc(); | |
// 解决华为手机的rem值偏小问题 | |
document.getElementsByTagName('head')[0].style.width = '20rem'; | |
document.getElementsByTagName('head')[0].style.height = '0px'; | |
document.getElementsByTagName('head')[0].style.display = 'block'; | |
// console.log(document.getElementsByTagName('head')[0].offsetWidth , docEl.clientWidth); | |
if(document.getElementsByTagName('head')[0].offsetWidth < docEl.clientWidth){ | |
scale = docEl.clientWidth/document.getElementsByTagName('head')[0].offsetWidth; | |
recalc(); | |
document.getElementsByTagName('head')[0].style.display = 'none'; | |
} | |
// 根据页面链接后缀,调整字体大小 | |
var fontsize = location.href.match(/fontsize=\d/ig); | |
if(fontsize && fontsize.length > 0 && /appdoc|body/ig.test(location.pathname)){ | |
fontsize = fontsize[0].replace('fontsize=',''); | |
switch(fontsize){ | |
case '0':scale = scale*0.8;break; | |
case '2':scale = scale*1.2;break; | |
case '3':scale = scale*1.5;break; | |
} | |
recalc(); | |
} | |
if (!doc.addEventListener) return; | |
win.addEventListener(resizeEvt, recalc, false); | |
})(document, window); | |
</script> |