js滚动条
/*滚动条在Y轴上的滚动距离*/
function ScrollTop()
{
var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0;
if (document.body)
{
bodyScrollTop = document.body.scrollTop;
}
if (document.documentElement)
{
documentScrollTop = document.documentElement.scrollTop;
}
scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
return scrollTop;
}
/*文档的总高度*/
function ScrollHeight()
{
var scrollHeight = 0, bodyScrollHeight = 0, documentScrollHeight = 0;
if (document.body)
{
bodyScrollHeight = document.body.scrollHeight;
}
if (document.documentElement)
{
documentScrollHeight = document.documentElement.scrollHeight;
}
scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
return scrollHeight;
}
/*浏览器视口的高度*/
function WindowHeight()
{
var windowHeight = 0;
if (document.compatMode == "CSS1Compat")
{
windowHeight = document.documentElement.clientHeight;
} else
{
windowHeight = document.body.clientHeight;
}
return windowHeight;
}
window.onscroll = function()
{
if (ScrollTop() + WindowHeight() + 5 >= ScrollHeight())
{
More();
}
};
js滚动条的更多相关文章
- jquery.nicescroll.min.js滚动条使用方法
jquery.nicescroll.min.js滚动条使用方法,Nicescroll 是制作自定义滚动条的jq插件.支持div,iframe,html等使用,兼容IE7-8,safari,firefo ...
- python实例编写(4)--js,滚动条,cookie,验证码,获取特定属性的元素,实现原理
一.调用js 执行方法:execute_script(script,*args) 场景一:在页面上直接执行调用js 场景二:在定位的某个元素上执行调用js 如:掩藏文字(提示插件 tooltip设置淡 ...
- jquery.nicescroll.min.js滚动条插件的用法
1.jquery.nicescroll.min.js源码 /* jquery.nicescroll 3.6.8 InuYaksa*2015 MIT http://nicescroll.areaaper ...
- JS滚动条下拉事件
<script type="text/javascript"> window.onscroll = function(){ var t = document.docum ...
- JS——滚动条
1.核心思想与之前的拖拽盒子是一样的 2.完全将鼠标在盒子中的坐标给滚动条是错的,因为这样会使滚动条顶部立刻瞬间移动到鼠标位置 3.必须在鼠标按下事件时记住鼠标在滚动条内部的坐标,再将鼠标在盒子中的坐 ...
- js 滚动条
<script type="text/javascript"> //文档高度1016 包含隐藏的margin和padding 实际1000 //文档1000 //窗口高 ...
- JS 滚动条事件
当滚动条滚动到最底部出发事件: $(window).scroll(function(){ if($(document).height()-$(this).scrollTop()-$(this).hei ...
- 原生JS滚动条位置处理
// 滚动条位置 var scrollPosition = { // 位置 result: 0, // 监听位置 rememberPosition: function () { var type = ...
- js滚动条滚动到某个元素位置
scrollTo(0,document.getElementById('xxx').offset().top);
随机推荐
- java 单元测试
---恢复内容开始--- 1/引入包:junit-4.11.jar|hamcrest-core-1.3(alilib里有) 2/与src同级建立一个文件夹,名为test,右击,Mark Directo ...
- tomcat的事件监听
//事件涉及的三个组件:事件源.事件对象.事件监听器 //一个总的事件监听器接口,所有不同分类的事件监听器都继承这个接口 public interface EventListener {} //例如 ...
- def语句常见错误
自觉不才,使用def语句时容易出现以下错误, 参考: 习题—25 http://www.2cto.com/shouce/Pythonbbf/ex25.html def add(): print &qu ...
- UITextField的属性设置
1.背景颜色 field.backgoundColor = [UIColor redColor]; 2.设置field文字 field.text = @"输入文字"; 3.设置fi ...
- android Tweened Animations
Android提供了两种类型的动画: 一类是Tween动画:提供了旋转.移动.伸展和淡出等效果: 第二类是Frame-by-frame动画:这一类Animations可以创建一个Drawable序列, ...
- css实现多行超出显示省略号?
可以实现,但是用的是-webkit-私有属性.我用js已经解决了.代码如下:text-overflow: -o-ellipsis-lastline;overflow: hidden;text-over ...
- Centos7 设置DNS 服务器
在CentOS 7下,手工设置 /etc/resolv.conf 里的DNS,过了一会,发现被系统重新覆盖或者清除了.和CentOS 6下的设置DNS方法不同,有几种方式: 1.使用全新的命令行工具 ...
- Subordinates
Subordinates time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Visual Studio中使用Git Flow
在VS下使用 GitFlow管理项目开发 1.右键将你的解决方案添加到源代码管理,如果你的VS没有安装git,会提示安装,安装完成之后,在团队资源管理可以看到如下界面 (图一) 2.安装gitflow ...
- git 忽略已跟踪的文件
对于未跟踪的文件,可以编辑.gitignore文件进行忽略. 对于已跟踪的文件,编辑.gitignore文件不会起作用,它只针对未被跟踪的文件,也就是你先设置规则,然后添加的新文件符合这些规则的就会被 ...