图片
CSS
JS广告
便捷
下载
解答
截图
高清壁纸
后台模板
PS插件
网页特效
Css新闻
推荐代码
页面应用
技术文章
图片展示
广告条
广告代码
软件类
在线工具
常用信息
动画制作
图片处理
辅助小工具
转换软件
其他
软件问题
系统问题
网页问题
常识整理
互联网价值
网站
图标
APP
按钮
公告
2013网站频道新版上线,功能持续完善中……
02.17
更新
mac系统PS数位板没有压感解决方案
01.27
查看windows10系统是否激活
08.31
windows10激活失败,亲测最有效的解决方法
08.31
Mac OS 您需要安装旧 Java SE 6 运行环境才能打开
04.10
Adobe adobeau2017英文转换为中文[汉化方法]
04.01
Mac电脑系统翻墙方法
05.26
最全手机APP中的尺寸规范
05.12
中文WebFont解决方案Font-Spider
09.02
互联网
JS控件
按钮
黑色
灰色
白色
蓝色
绿色
黄色
橙色
>
代码
>
其他整理
网页TOP返回顶部缓冲效果
上一篇
下一篇
0
作者:vip_260 来源:未知 日期:2011/1/17 10:21:26 人气:
标签:
网页TOP返回顶部缓冲效果function Preview(){ var TestWin=open(''); TestWin.document.write(code.value);}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tr
网页TOP返回顶部缓冲效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>网页TOP返回顶部缓冲效果</title> </head> <body> <script language="javascript"> /*-------------------------------------------------------------------------- * http://www.v404.cn/ * /*--------------------------------------------------------------------------*/ Scroller = { // control the speed of the scroller. // dont change it here directly, please use Scroller.speed=50; speed:10, // returns the Y position of the div gy: function (d) { gy = d.offsetTop if (d.offsetParent) while (d = d.offsetParent) gy += d.offsetTop return gy }, // returns the current scroll position scrollTop: function (){ body=document.body d=document.documentElement if (body && body.scrollTop) return body.scrollTop if (d && d.scrollTop) return d.scrollTop if (window.pageYOffset) return window.pageYOffset return 0 }, // attach an event for an element // (element, type, function) add: function(event, body, d) { if (event.addEventListener) return event.addEventListener(body, d,false) if (event.attachEvent) return event.attachEvent('on'+body, d) }, // kill an event of an element end: function(e){ if (window.event) { window.event.cancelBubble = true window.event.returnValue = false return; } if (e.preventDefault && e.stopPropagation) { e.preventDefault() e.stopPropagation() } }, // move the scroll bar to the particular div. scroll: function(d){ i = window.innerHeight || document.documentElement.clientHeight; h=document.body.scrollHeight; a = Scroller.scrollTop() if(d>a) if(h-d>i) a+=Math.ceil((d-a)/Scroller.speed) else a+=Math.ceil((d-a-(h-d))/Scroller.speed) else a = a+(d-a)/Scroller.speed; window.scrollTo(0,a) if(a==d || Scroller.offsetTop==a)clearInterval(Scroller.interval) Scroller.offsetTop=a }, // initializer that adds the renderer to the onload function of the window init: function(){ Scroller.add(window,'load', Scroller.render) }, // this method extracts all the anchors and validates then as # and attaches the events. render: function(){ a = document.getElementsByTagName('a'); Scroller.end(this); window.onscroll for (i=0;i<a.length;i++) { l = a[i]; if(l.href && l.href.indexOf('#') != -1 && ((l.pathname==location.pathname) || ('/'+l.pathname==location.pathname)) ){ Scroller.add(l,'click',Scroller.end) l.onclick = function(){ Scroller.end(this); l=this.hash.substr(1); a = document.getElementsByTagName('a'); for (i=0;i<a.length;i++) { if(a[i].name == l){ clearInterval(Scroller.interval); Scroller.interval=setInterval('Scroller.scroll('+Scroller.gy(a[i])+')',10); } } } } } } } // invoke the initializer of the scroller Scroller.init(); </script> 把滚动条拖动到页面底部,然后点击“返回TOP”看效果 <a name="top" id="top"></a><br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <a href="#top">返回TOP</a> </body> </html>
运行代码
加关注
关于我们
帮助中心
意见反馈
设计导航
Copyright 2008
网站频道
All Rights Resverved.
提供:网页特效 JS广告 网站截图 酷站推荐 交流群:3506863
页面执行时间0.1094秒 查询数据库3次