Daniela Răducanu
Daniela Răducanu

Reputation: 47

jquery document height and window height

I have a problem with following jquery code

if ($(window).scrollTop() >= ($(document).innerHeight() - $(window).innerHeight())) 

In Google chrome the code is working perfectly but in Firefox or IE it doesn't. There's any way to rewrite it ?

Thank you!

EDIT:

After some debug.. the value of document height - window height is bigger than "window.scrollTop" so the following code is a possible fix

if ($(window).scrollTop() >= ($(document).innerHeight() - $(window).height() - 2)) {

Upvotes: 0

Views: 7422

Answers (1)

Gaurav
Gaurav

Reputation: 28775

Use innerHeight() instead of height()

There are some issues with height() and IE

I faced the same problem and I used innerHeight() and it worked.

Upvotes: 3

Related Questions