js滚动条事件

function move2(){
var content = document.getElementById("div");
//alert(content.offsetTop+"--"+document.documentElement.scrollTop);
var top =document.documentElement.scrollTop;
content.style.top=top+"px";
}

function move1(){
                  //鼠标滚动
document.body.onmousewheel = function(){
move2();
}
//拖动滚动条
window.onscroll = function(){
move2();
}

}

你可能感兴趣的:(滚动条)