获取滚屏高度及鼠标所在高度
2012-1-30 11:26 Monday  

分类: Javascript 评论(0) 浏览(14291)

function bodyHeight(){
var cobj = document.body;
while(cobj.scrollTop == 0 && cobj.parentNode) {
   if(cobj.tagName.toLowerCase() == 'html') break;
   cobj = cobj.parentNode;
}
return cobj.clientHeight;
}
function scrolltop(){
var cobj = document.body;
while(cobj.scrollTop == 0 && cobj.parentNode) {
   if(cobj.tagName.toLowerCase() == 'html') break;
   cobj = cobj.parentNode;
}
return cobj.scrollTop;
}

 

 

不过以上在Jquery中就非常简单了,$(window).height()  + $(window).scrollTop();

鼠标Y event.clientY
鼠标X event.clientX

+1 5

留下你的看法: