20180530_《Javascript获取网页大,元素位置(摘)》

  function getViewport(){
    if (document.compatMode == "BackCompat"){
      return {
         document.body.clientWidth,
        height: document.body.clientHeight
      }
    } else {
      return {
         document.documentElement.clientWidth,
        height: document.documentElement.clientHeight
      }
    }
  }

  

//js 获取元素位置方法
getBoundingClientRect()

  

原文地址:https://www.cnblogs.com/beesky520/p/9108711.html