king
2019-07-15 12c4d9c66a08101960107571b6e0aa3cf7b02874
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*** 
    created by lee
    目前默认以1200 / 720 为分界线 
    需要自行设置html fontSize  100px
    请使用rem em 
***/
 
 
;
(function(win, doc, undefined) {
    let resizeWid = 'orientationchange' in win ? 'orientationchange' : 'resize',
        reSize = function() {
            let docEle = doc.documentElement,
                docWid = Number(window.innerWidth);
            if (docWid === undefined) return;
            (docWid > 750 & docWid < 1200) ? docEle.style.fontSize = `${docWid / 1200 * 100}px`: false;
            (docWid > 1200) ? docEle.style.fontSize = `100px`: false;
            (docWid < 750) ? docEle.style.fontSize = `${docWid / 750 * 100}px`: false;
        };
    win.addEventListener(resizeWid, reSize, false);
    doc.addEventListener('DOMContentLoaded', reSize, false);
})(window, document);
 
 
 
// ; (function (win, doc, Size, undefined) {
//     let resizeWid = 'orientationchange' in win ? 'orientationchange' : 'resize',
//         reSize = function () {
//             let docEle = doc.documentElement,
//                 docWid = Number(window.innerWidth) || document.body.clientWidth;
//             if (docWid === undefined) return;
//             (docWid <= Size) ? docEle.style.fontSize = `${docWid / Size * 100}px` : docEle.style.fontSize = '100px';
//         };
//     win.addEventListener(resizeWid, reSize, false);
//     doc.addEventListener('DOMContentLoaded', reSize, false);
// })(window, document, 1200);
 
(function(win) {
    let fn = function() {
        win.scrollTo(0, 0);
    }
    win.addEventListener("beforeunload", fn);
})(window);