解决因为手机设置字体大小导致h5页面在webview中变形的BUG

function htmlFontSize(){ var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); var width = w > h ? h : w; width = width > 720 ? 720 : width var fz = ~~(width*100000/36)/10000 document.getElementsByTagName("html")[0].style.cssText = 'font-size: ' + fz +"px"; var realfz = ~~(+window.getComputedStyle(document.getElementsByTagName("html")[0]).fontSize.replace('px','')*10000)/10000 if (fz !== realfz) { document.getElementsByTagName("html")[0].style.cssText = 'font-size: ' + fz * (fz / realfz) +"px"; }}


源自:http://blog.csdn.net/FungLeo/article/details/73309396


你可能感兴趣的:(解决因为手机设置字体大小导致h5页面在webview中变形的BUG)