1

I have some Javascript code where I need the dimensions of my window, therefore I've used the classic jQuery $(window).height()

This works perfectly on one version of my website, but returns a wrong value (lower than normal) on another. I tested by displaying both in two tabs of the same browser, and I get two different values.

Codewise, I can't figure out the difference between both versions that may cause the problem, so I'm just looking for clues about what could possibly be wrong or how to debug.

I'm aware similar topics have already been discussed on Stack Overflow, but I haven't found a relevant answer. You should know that:

  • I do have <!doctype html> at the top of my DOM in both versions
  • The problem occurs at least on Chrome and Firefox
Telergoel
  • 353
  • 1
  • 13
  • 2
    Normally differences like this are because of collapsed margins or padding, but it's impossible to say without seeing an example. It shouldn't be too difficult for you to compare the differences between your HTML though. – Rory McCrossan May 14 '19 at 09:43
  • 1
    Take a look at this: https://stackoverflow.com/a/3437825/1990724 – Martin M May 14 '19 at 09:49
  • I can't find any big difference in both HTML, however I can investigate on collapsed margins. How could they affect the windows height? – Telergoel May 14 '19 at 09:52
  • @MartinM, I've read this topic and for what I can tell I'm already using what I should use to get the window's height. The problems remains the same if I replace my jQuery with window.innerHeight – Telergoel May 14 '19 at 10:04
  • Could you give a example? – Martin M May 14 '19 at 11:26

0 Answers0