现在的位置: 首页 > 综合 > 正文

让一个DIV在页面右边并跟随滚动条移动

2013年02月12日 ⁄ 综合 ⁄ 共 705字 ⁄ 字号 评论关闭

function getScroll() {   var top, left, width, height;   if (document.documentElement && document.documentElement.scrollTop) {    top = document.documentElement.scrollTop;    left = document.documentElement.scrollLeft;    width = document.documentElement.scrollWidth;    height = document.documentElement.scrollHeight;   }   else if (document.body) {    top = document.body.scrollTop;    left = document.body.scrollLeft;    width = document.body.scrollWidth;    height = document.body.scrollHeight;   }   return { top: top, left: left, width: width, height: height };  }

 function scall(){   var v = getScroll();   //alert(v.top);   var e = document.getElementById("float_right");   e.style.top = ((v.top) + 50) + "px";  //纵滚动条离顶部距离  }

 window.onload = scall ;  window.onscroll = scall ;


抱歉!评论已关闭.