(javascript) 获取鼠标事件发生坐标的问题

软件环境ie 6,vs2005,今天在弄一个需要获取事件位置的坐标的时候发现网上很多人用的document.body.scrollTop一直都为0,百思不得其解,于是上网搜索看看该怎么使用scrollTop才对,居然很幸运的被我发现一个网页上面(http://forums.digitalpoint.com/showthread.php?t=11965)有人给出了答案,说是ie6下面如果要使用scrollTop得用document.documentElement.scrollTop才能获取得到滑动条滑动的偏移量,并给出了代码来解决兼容其他浏览器的问题

if (document.documentElement && !document.documentElement.scrollTop)
// IE6 +4.01 but no scrolling going on
else if (document.documentElement && document.documentElement.scrollTop)
// IE6 +4.01 and user has scrolled
else if (document.body && document.body.scrollTop)
// IE5 or DTD 3.2
经过在ie上面简单测试(ie6)该答案是正确的。
原文地址:https://www.cnblogs.com/ocean2000/p/851986.html