//屏幕尺寸 (function(doc, win) { var docel = doc.documentelement, isios = navigator.useragent.match(/iphone|ipod|ipad/gi), dpr = isios ? math.min(win.devicepixelratio, 3) : 1, dpr = window.top === window.self ? dpr : 1, //被iframe引用时,禁止缩放 dpr = 1, // 首页引用iframe,强制为1 scale = 1 / dpr, resizeevt = 'orientationchange' in window ? 'orientationchange' : 'resize'; docel.dataset.dpr = win.devicepixelratio; if (navigator.useragent.match(/iphone/gi) && screen.width == 375 && win.devicepixelratio == 2) { docel.classlist.add('iphone6') } if (navigator.useragent.match(/iphone/gi) && screen.width == 414 && win.devicepixelratio == 3) { docel.classlist.add('iphone6p') } var metael = doc.createelement('meta'); metael.name = 'viewport'; metael.content = 'initial-scale=' + scale + ',maximum-scale=' + scale + ', minimum-scale=' + scale; docel.firstelementchild.appendchild(metael); var recalc = function() { var width = docel.clientwidth; if (width / dpr > 750) { width = 750 * dpr; } docel.style.fontsize = 100 * (width / 750) + 'px'; }; recalc() if (!doc.addeventlistener) return; win.addeventlistener(resizeevt, recalc, false); })(document, window);