1234567891011121314151617181920212223242526272829303132 |
- !(function(win, doc) {
- const MOBILE_WIDTH = 710 // 750 refer to Bootstrap's responsive design
- function $_getDevice() {
- const rectWidth = doc.documentElement.clientWidth
- if(rectWidth < MOBILE_WIDTH){
- return 'mobile'
- }else {
- return 'pc'
- }
- }
- function setFontSize(device) {
- var docEl = doc.documentElement;
- var winWidth = docEl.clientWidth;
- console.log("setFontSize===",device);
- if(device === 'mobile'){
- doc.documentElement.style.fontSize = (winWidth / 750) * 100 + "px";
- }else{
- doc.documentElement.style.fontSize = 1 + "px";
- }
-
- }
- var userAgent = navigator.userAgent;
- win.addEventListener("resize", function() {
- if (navigator.userAgent !== userAgent) {
- location.reload();
- }
- });
- var device = $_getDevice()
- setFontSize(device);
- })(window, document);
|