Skip to content

Latest commit

 

History

History
25 lines (23 loc) · 721 Bytes

前端监控及前端埋点.md

File metadata and controls

25 lines (23 loc) · 721 Bytes
    <script>
      (function (win, doc) {
        function setFontSize () {
          var winWidth = window.innerWidth;
          doc.documentElement.style.fontSize = (winWidth / 750) * 100 + 'px'
        }
        var event = 'onorientationchange' in win ? 'orientationchange' : 'resize'
        var timer = null
        win.addEventListener(event, function (){
          clearTimeout(timer)
          timer = setTimeout(setFontSize, 300)
        }, false)
        win.addEventListener('pageshow', function(e) {
          if (e.persisted) {
            clearTimeout(timer)
            timer = setTimeout(setFontSize, 300)
          }
        })

        setFontSize()

      })(window, document)
    </script>