悬浮框保证在中间js

lastScrollY=0;//固定层top值
function heartBeat(){
var diffY;//网页被卷起来的高度
if (document.documentElement && document.documentElement.scrollTop){//判定是否直接document.documentElement或者被被卷起的值(ie)
diffY = document.documentElement.scrollTop;
}else if (document.body){//火狐
diffY = document.body.scrollTop;
}else
{/*Netscape stuff*/}

//alert(diffY);
percent=.1*(diffY-lastScrollY);
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.getElementById("zixunss").style.top=parseInt(document.getElementById("zixunss").style.top)+percent+"px";

lastScrollY=lastScrollY+percent;
//alert(lastScrollY);
}

window.setInterval("heartBeat()",1)



你可能感兴趣的:(悬浮框保证在中间js)