<style type="text/css">
.backToTop {
display: none;
width: 17px;
line-height: 1;
padding: 5px;
background-color: black;
color: #fff;
font-size: 18px;
text-align: center;
position: fixed;
_position: absolute;
right: 2px;
bottom: 100px;
_bottom: "auto";
cursor: pointer;
opacity: .7;
filter: Alpha(opacity=70);
}
</style>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
(function() {
var $backToTopTxt = "返回顶部", $backToTopEle = $('<div class="backToTop"></div>').appendTo($("body"))
.text($backToTopTxt).attr("title", $backToTopTxt).click(function() {
$("html, body").animate({ scrollTop: 0 }, 120);
}), $backToTopFun = function() {
var st = $(document).scrollTop(), winh = $(window).height();
(st > 0)? $backToTopEle.show(): $backToTopEle.hide();
//IE6下的定位
if (!window.XMLHttpRequest) {
$backToTopEle.css("top", st + winh - 166);
}
};
$(window).bind("scroll", $backToTopFun);
$(function() { $backToTopFun(); });
})();
</script>