internet explorer - Javascript get scroll amount in IE -
i have div scrollable want conditionally stop scrolling.
the code like:
if(thediv.scrolltop + thediv.clientheight + thisscrollamount > thediv.scrollheight) stopscrolling();
how can amount scroll scrolled? (i know event.wheeldelta
typically +-120, seems amount scrolled when 1 scrolls can quite different that.)
edit apologies. seems question unclear. looking how div would scroll if event not canceled it's handler. assuming took on different values, appears take on values +- 120.
perhaps should deleted.
//works pretty <style type="text/css"> #divtest{width:150px;height:200px;overflow:auto} </style> <script> var amountcanscroll = 400 function maxscroll( ){ if( document.getelementbyid('divtest').scrolltop > amountcanscroll){ document.getelementbyid('divtest').scrolltop = amountcanscroll; } } </script> <body><div id="divtest" onscroll="maxscroll()" > 1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/> 1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/> 1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/> 1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/> 1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/> 1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/> 1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/> 1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/>1<br/> </div> </body>
Comments
Post a Comment