![]() |
IE issue regarding pageYOffset & offsetTop
I created a piece of code for a cross-brower/cross-device solution for locking a div on a custom vBulletin page. The div locks and scrolls along with the page scrolling as soon as it's reached.
To do this, I make use of another div that is on the same height as the div that needs to lock and scroll along. Also, no fixed position is used because mobile behavior would make the div disappear completely. It's not the prettiest solution, but at least it seems the most potential as a cross-browser and device solution. However, when adding it, it works in all majors browsers and on platforms including iOS and Android, but it does not work in IE. For some mysterious reason, IE does not seem to be able to get the pageYOffset and/or offsetTop values. Code:
<script type="text/javascript">Thanks in advance for the help!! |
Quote:
Code:
Math.max(document.documentElement.scrollTop, document.body.scrollTop); |
Code:
window.onscroll = function (e) { |
Quote:
Also, scrollTop (both the javascript and its jquery varient) for some reason gave values that were terribly off. Really seems like something from vBulletin conflicting with it. But.. I ended up adding getBoundingClientRect for whichever browser and device supports that. Works like a charm and no conflicting with vBulletin so we're all good now. Thanks for the help though, Logic Ali and vwphillips. PS: I edited the main post but it disappeared (that new 'Moderated Threads and Posts' system is waaaay heavy). When it's approved again, could anyone mark this as resolved for me? Thanks! |
Quote:
|
| All times are GMT +1. The time now is 03:54 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.