<script type="text/javascript">
var tips;
var theTop = 5/*这是默认高度,越大越往下*/;
var old = theTop;
var pos;
function initFloatTips() {
tips = document.getElementById('floatTips');
moveTips();
};
function moveTips() {
var tt=5000;
//alert("dE = " + document.documentElement.scrollTop);
//alert('bE = ' + document.body.scrollTop);
if (document.documentElement && document.documentElement.scrollTop) {
pos = document.documentElement.scrollTop
}
else if (document.body) {
pos = document.body.scrollTop;
}else if (window.innerHeight) {
pos = window.pageYOffset
}
pos=pos-getTop(tips)+theTop;
pos=getTop(tips)+pos/10;
if (pos < theTop) pos = theTop;
if (pos != old) {
tips.style.top = pos+"px";
//tt=0;
}
old = pos;
setTimeout(moveTips,tt);
}
function getTop(e){
var offset=e.offsetTop;
if(e.offsetParent!=null) offset+=getTop(e.offsetParent);
return offset;
}
</script>
滚动窗口js
最新推荐文章于 2024-05-31 23:45:01 发布