I have a page where I need to dynamically load ajax contents when the user scrolls down. The problem is that jQuery does not return the correct window height. I have used this function before and have never seen it crash, but for some reason it will return the same value as the height of the document. I have a test page here: bangstyle.com/test-images
I encoded a warning to display when the page loads, and also every time the user scrolls 500 pixels below:
function scroller() { if($(window).scrollTop() > 500){ delay(function(){ //200ms wait pagecounter++; sideshow(); alert("window height: " + $(window).height() + " scrolltop: " + $(window).scrollTop() + " document height: " + $(document).height()); return false; }, 200 ); } }
I tried posting this before but I deleted it since I didnโt get the solution. I hope you can post a link to my test page. BTW I tested this on Mac Safari and Mac FF. I ran the same code on other pages and it works great. I feel that there should be something in the home of this page that makes JS fail, but I don't know what it would be.
javascript jquery height window
Joel Joel Binks Oct 08 '12 at 18:27 2012-10-08 18:27
source share