`
sbiigu
  • 浏览: 160059 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

滚动窗口js

 
阅读更多
<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>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics