mmuruganandam
asked on
How to findout the ScrollBar Position using JavaScript?
within the <body> tag, a <div id="content"> ... rest of the body contents goes here ... </div></body>
Upon rendering the page, i have the scroll bars (vertical) enabled. I can able to scroll it.
but the JS calls, document.body.scrollLeft and document.body.scrollTop are always giving 0 (Zero).
I am testing this with IE. It works fine in FireFox.
What is the exact problem in this with IE?
Thanks,
Muruga
Upon rendering the page, i have the scroll bars (vertical) enabled. I can able to scroll it.
but the JS calls, document.body.scrollLeft and document.body.scrollTop are always giving 0 (Zero).
I am testing this with IE. It works fine in FireFox.
What is the exact problem in this with IE?
Thanks,
Muruga
ASKER
>>document.body.scrollTop
Is there any other way than this.
Because, this is not working for me. We have some intranet standards.
All the stylesheets are defined even for DIV.
Can you give me a different solution?
Thanks
Is there any other way than this.
Because, this is not working for me. We have some intranet standards.
All the stylesheets are defined even for DIV.
Can you give me a different solution?
Thanks
Maybe you scrollbar is inside the DIV object, and not the BODY. You can try to retrieve the "scrollTop" property of the DIV element itself.
ASKER
I have found out the solution for this.
It can be achieved by document.documentElement.s crollTop.
It is working fine.
Thanks for your support as always.
I am confused whether to delete this question or give away points.
Any suggestions guys....
It can be achieved by document.documentElement.s
It is working fine.
Thanks for your support as always.
I am confused whether to delete this question or give away points.
Any suggestions guys....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<html>
<head>
<script>
function moveMenu() {
for(i = 1 ; i < 5; i++) {
mDiv = document.getElementById('d
if(mDiv)
{
mDiv.style.top = (i * 21) + document.body.scrollTop;
window.status = "top: "+mDiv.style.top;
}
}
}
</script>
</head>
<body onScroll="moveMenu()">
<div name="menu_links_1" id="div_menu_links_1" style="top=21; left:0; z-index:106; background-color:yellow; position:absolute;">
<table>
<tr><td>MenuA</td>
<td>MenuB</td>
<td>MenuC</td></tr>
</table>
</div>
<table height="1600" border="1">
<tr><td></td></tr>
</table>
</body>
</html>