zoukankan      html  css  js  c++  java
  • 页面滚动可视区域的获取

    document.scrollingElement属性返回文档的滚动元素。也就是说,当文档整体滚动时,到底是哪个元素在滚动。
    标准模式下,这个属性返回的文档的根元素document.documentElement(即<html>)。兼容(quirk)模式下,返回的是<body>元素,如果该元素不存在,返回null。
    
    // 页面滚动到浏览器顶部
    document.scrollingElement.scrollTop = 0;
    或者也可以像下面
    document.documentElement.scrollTop  = 0
     document.body.scrollTop = 0;
    
     获取可视区域距离页面顶部的距离
     scrollTop = document.scrollingElement.scrollTop
    scrollTop=document.documentElement.scrollTop  || document.body.scrollTop
    
  • 相关阅读:
    6 Django的视图层
    5 Django-2的路由层(URLconf)
    4 Django简介
    3 web框架
    2 http协议
    1 web应用
    15-jQuery补充
    14-jQuery的ajax
    13-轮播实现(各种)
    12-事件委托(事件代理)
  • 原文地址:https://www.cnblogs.com/Dark-fire-liehuo/p/10605873.html
Copyright © 2011-2022 走看看