用途一:"返回顶部";
window.onscroll = function(){
var t = document.documentElement.scrollTop || document.body.scrollTop;
var top_div = document.getElementById( "top_div" );
if( t >= ) {
top_div.style.display = "inline";
} else {
top_div.style.display = "none";
}
}
用途二:"商品详情菜单漂浮" 当鼠标滚动到一定位置 会有一个导航漂浮起来
window.onscroll = function(){
var t = document.documentElement.scrollTop || document.body.scrollTop;
var Div = document.getElementById( "fix_goods" );
if( t <= ) {
Div.style.position = "";
Div.style.top = "";
} else {
//Div.style.display = "none";
Div.style.position = "fixed";
Div.style.top = "-10px"; }
}
原文来源:http://www.cnblogs.com/wesky/admin/EditPosts.aspx?postid=3303694&update=1