一个经典的回到顶部效果,兼容各种浏览器
2011-10-10 10:48
197 查看
<!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>
<title>回到顶部</title>
<script src="/js/library/jquery-1.4.1.min.js" type="text/javascript"></script>
</head>
<body>
<div style="height:1200px"></div>
<a href="#" style="position:fixed; right:0px; bottom:0px; z-index:100; _position:absolute; _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight -60));">
<img src="top.gif" border="0" id="returnTop" />
</a>
<script type="text/javascript">
//置顶效果
$(function () {
$("#returnTop").click(function () {
$(this).parent().hide();
document.documentElement.scrollTop = 0;
});
});
window.onscroll = function () {
if (document.documentElement.scrollTop > 10) {
$("#returnTop").parent().show();
} else {
$("#returnTop").parent().hide();
}
}
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>回到顶部</title>
<script src="/js/library/jquery-1.4.1.min.js" type="text/javascript"></script>
</head>
<body>
<div style="height:1200px"></div>
<a href="#" style="position:fixed; right:0px; bottom:0px; z-index:100; _position:absolute; _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight -60));">
<img src="top.gif" border="0" id="returnTop" />
</a>
<script type="text/javascript">
//置顶效果
$(function () {
$("#returnTop").click(function () {
$(this).parent().hide();
document.documentElement.scrollTop = 0;
});
});
window.onscroll = function () {
if (document.documentElement.scrollTop > 10) {
$("#returnTop").parent().show();
} else {
$("#returnTop").parent().hide();
}
}
</script>
</body>
</html>
相关文章推荐
- 一个audio标签在各浏览器上各种不兼容,各种小毛病,现在还是flash最靠谱
- 兼容各种主流浏览器的CSS阴影效果
- 一个酷炫的,基于HTML5,Jquery和Css的全屏焦点图特效,兼容各种浏览器
- 兼容各种浏览器的文字循环无缝滚动效果
- CSS 实现图片灰度效果 兼容各种浏览器
- 背景图拉伸效果兼容各种浏览器
- My97DatePicker,一个兼容所有浏览器的日历选择脚本(相当经典)
- CSS 实现图片灰度效果 兼容各种浏览器
- 遮层效果,兼容各种浏览器ie6--ie9,火狐,谷歌,360都ok
- 继上一个三级联动的补充--使用jQuery编写各种浏览器兼容简易项目
- 手写的一个兼容各种浏览器的javascript getStyle函数(获取元素的样式)
- 继上一个三级联动的补充--使用jQuery编写各种浏览器兼容简易项目
- CSS阴影效果(兼容各种浏览器)
- 继上一个三级联动的补充--使用jQuery编写各种浏览器兼容简易项目
- 一个兼容各种浏览器的层透明的css hack
- CSS 实现图片灰度效果 兼容各种浏览器
- 手写的一个兼容各种浏览器的javascript getStyle函数(获取元素的样式)
- 使用CSS实现透明边框的效果——兼容当前各种主流浏览器[xyytIT]
- 封装的一个JS拖拽效果,兼容所有主流浏览器
- [原创]一个纯css实现兼容各种主流移动pc浏览器的时间轴