1.jq程式碼:

<script type="text/javascript">
$(function() {
$("#tbox").click(scrollToTop);
});
function scrollToTop() {
$("body,html").animate({
scrollTop: 0
}, 600);
return false;
}
</script>
<script type="text/javascript">
function scrollToTop() {
$("body,html").animate({
scrollTop: 0
}, 600);
return false;
} $(function() {
// $("#tbox").hide();
$(window).scroll(function() {
if ($(this).scrollTop() > 100) {
$("#tbox").fadeIn();
} else {
$("#tbox").fadeOut();
}
});
$("#atop").click(scrollToTop);
});
</script>

1.css程式碼:

*{ padding:0px; margin:0px;}
*html{background-image:url(about:blank);background-attachment:fixed;}/*解決IE6下滾動抖動的問題*/
#tbox{float:right; position:fixed; right:2px; bottom:20px;
_position:absolute;
_bottom:auto;
_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));_margin-bottom:20px;}/*解決IE6下不相容 position:fixed 的問題*/