1.处理ie6不兼容position:fixed的问题
有一条没截全:_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));
2.主要是滚动的高度在浏览器之间支持问题, document.body.scrollTop
因为: document.body.scrollTop 主要是谷歌浏览器,360浏览器,没DOCTYPE的ie等支持
document.documentElement.scrollTop 则是火狐浏览器,有DOCTYPE的ie浏览器支持
最麻烦的是苹果的Safari 竟然只对window.pageYOffset支持
//document.all // 只有ie认识
//document.body.clientHeight // 文档的高,屏幕的文档区域的高
//document.documentElement.clientHeight // 有效的高,屏幕可视的高
//document.documentElement.scrollHeight // 屏幕的总高度
//document.documentElement.scrollTop // 滚动的高
简单设置置顶按钮样式,注意要先隐藏起来
<style type="text/css">
#scroll {
width: 62px;
height: 50px;
right: 50px;
bottom: 50px;
display: none;
cursor: pointer;
position: fixed;
background: url(img/gotop.png);
}
</style>
多写点东西,撑出滚动条
js代码