标签:
window.onscroll = _onScroll;
function _onScroll(){
var aside = document.getElementsByClassName(‘aside‘)[0];
var scrollTop = document.documentElement.scrollTop //在ie下
+document.body.scrollTop ;//其他浏览器
if(scrollTop>230){
aside.style.position=‘fixed‘
aside.style.top =‘0px‘
}else{
aside.style.position=‘absolute‘
aside.style.top =‘230px‘
}
console.log(scrollTop)
};
标签:
原文地址:http://www.cnblogs.com/victorPPW/p/4935781.html