zoukankan
html css js c++ java
回到顶部
<!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" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> <title>回到顶部 - 豪情</title> <style type="text/css"> *{ margin:0; padding:0;} body{font:12px/1.125 Arial,Helvetica,sans-serif;background:#fff;} a:focus,input,textarea{outline-style:none;} a{color:#0a8cd2;text-decoration:none;} a:hover{text-decoration:underline;} .none{display:none} .demo{ height:2000px;} .gotop{ 18px;line-height:1.2;padding:7px 0px 7px 2px;background-color:#000;color:#fff;font-size:12px;text-align:center;position:fixed;_position:absolute;right:0px;bottom:100px;_bottom:"auto";cursor:pointer;opacity:0.6;filter:Alpha(opacity=60);border-radius:5px 0 0 5px; display:none;} .gotop:hover{ text-decoration:none;opacity:0.7;filter:Alpha(opacity=70);} </style> </head> <body> <div class="demo"></div> <script type="text/javascript"> (function(){ function viewSize(){ var doc = document, de = doc.documentElement; return { 'width': (window.innerWidth || (de && de.clientWidth) || doc.body.clientWidth), 'height': (window.innerHeight || (de && de.clientHeight) || doc.body.clientHeight) }; } function getScrollTop(){ return document.documentElement.scrollTop || document.body.scrollTop; } var btn = null, timer = 0; function apendScroll(){ btn = document.createElement('a'); btn.href = 'javascript:void(0)'; btn.className = 'gotop'; btn.innerHTML = '回到顶部'; document.body.appendChild(btn); } apendScroll(); function ie6Top(){ if(!window.XMLHttpRequest){ btn.style.top = getScrollTop() + viewSize().height - 200 + 'px'; } } window.onscroll = function(){ btn.style.display = getScrollTop() > 0 ? 'block' : 'none'; ie6Top(); } btn.onclick = function(){ timer = setInterval(function(){ var scrollTop = getScrollTop(); var iSpeed = Math.floor(- scrollTop / 8); if(scrollTop == 0){ clearInterval(timer); } ie6Top(); document.documentElement.scrollTop = document.body.scrollTop = scrollTop + iSpeed; }, 30); } }()); </script> </body> </html>
运行代码
查看全文
相关阅读:
如何操作3D中的摄像机
软件开发的未来,是MDA/MDD/面向模式/Plugin IDE吗?[转]
Hibernate3一个不错的入门介绍
C#中的== Equals 与 Java 的== Euqals
The Attributes property of a ListItem control only works within an HtmlSelect control
WebWork 与 Struts
会计基本流程
常用 js 函数
SQL中的sysobjects与syscolumns
一个Struts2的的辅助工具
原文地址:https://www.cnblogs.com/jikey/p/2980351.html
最新文章
html获得当前焦点所在的控件
bing map 画圆,其他百度地图、谷歌地图、搜搜地图、搜狗地图等稍微修改即可
springbootmybatis plus增删改查CURD操作
VMware>centos7>docker18.09.1>mysql5.7
springboot整合redis
mybatisplus代码生成器
springmvc请求参数绑定
springboot上传文件
springboot+mybatis plus+mysql
mybatismapper.xml传参_动态sql
热门文章
springboot整合Mail
cocos2d 工具
OpenGL基础图形编程(一)
ios cocos2d cocos3d 常见问题
卡尔曼滤波简介
iphone 绘图
3D中的绘制流水线(Render/Display的工作流程)
TexturePacker生成动画脚本
cocos 有用的API
ObjectiveC单例实现
Copyright © 2011-2022 走看看