js获取高度

xiaoxiao2021-02-28  46

//获取文档完整的高度              function getScrollHeight() {                   return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);              }           //获取当前可视范围高度          function getClientHeight() {               var clientheight = 0;               if (document.body.clientHeight && document.documentElement.clientHeight) {                  clientheight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);              } else {                  clientheight = Math.max(document.body.clientHeight, document.documentElement.clientHeight);              }               return clientheight;          }           //获取滚动条的高度          function getScrollTop() {               var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);               return scrollTop;          }
转载请注明原文地址: https://www.6miu.com/read-2612657.html

最新回复(0)