• js获取页面元素距离浏览器工作区顶端的距离


    先介绍几个属性:(暂时只测了IE和firefox,实际上我工作中用到的最多的是chrome)

     网页被卷起来的高度/宽度(即浏览器滚动条滚动后隐藏的页面内容高度)

    (javascript)        document.documentElement.scrollTop //firefox

    (javascript)        document.documentElement.scrollLeft //firefox

    (javascript)        document.body.scrollTop //IE

    (javascript)        document.body.scrollLeft //IE

    (jqurey)             $(window).scrollTop() 

    (jqurey)             $(window).scrollLeft()

     网页工作区域的高度和宽度  

    (javascript)       document.documentElement.clientHeight// IE firefox       

    (jqurey)             $(window).height()

     元素距离文档顶端和左边的偏移值  

    (javascript)        DOM元素对象.offsetTop //IE firefox

    (javascript)        DOM元素对象.offsetLeft //IE firefox

    (jqurey)             jq对象.offset().top

    (jqurey)             jq对象.offset().left

    获取页面元素距离浏览器工作区顶端的距离

     页面元素距离浏览器工作区顶端的距离  =  元素距离文档顶端偏移值  -   网页被卷起来的高度  

    即:

     页面元素距离浏览器工作区顶端的距离 =  DOM元素对象.offsetTop  -  document.documentElement.scrollTop 

    转载自:https://www.cnblogs.com/dreamboycx/p/11676588.html

  • 相关阅读:
    WebService-01-使用jdk发布第一个WebService服务并调用
    Oracle触发器
    java调用存储过程、存储函数
    存储过程/存储函数
    SQL查询排名第二名的信息
    sql行转列
    SELECT列表中的标量子查询
    sql子查询在insert、update、delete中的应用
    sqlserver存储过程中,set rowcount 0是什么意思?
    固态硬盘安装系统
  • 原文地址:https://www.cnblogs.com/smile-fanyin/p/14282608.html
Copyright © 2020-2023  润新知