Too big number of $(window).height() on wordpress Too big number of $(window).height() on wordpress wordpress wordpress

Too big number of $(window).height() on wordpress


It took me hours/days to debug this baby, but I finally got it. Believe or not, but I haven't had such bug for YEARS!! What a nasty bug.

I am not saying you had the exact problem, however, this thread is exactly what I was facing. I was 100% sure that my html is set to strict.

However, as soon as I did "Inspect element" in Chrome, the actual definition of strict DOCTYPE was gone. So I checked other websites, and I immediately realized that there is something extremly fishy going on, this shouldn't be happening. Who ate my strict doctype?

Not only that, but I noticed that the contents of HEAD moved to <body> and other weird things were happening.

I did what any reasonable human would do, I speculated that all my time was wasted on this stupid UTF-8 BOM, as I've had many problems with that in the past. Oh boy was I correct.

Everything started to work flawlessly, after I've switched to UTF-8 without bom. Notice that the interesting thing is: my website seemed to work 100%, even with messed up HTML(I never noticed that browser interpreted it way incorrectly).

Why was my file encoded as UTF-8 with bom at first place & why should it even affect browser? I have no idea.


Ok, I got it. I'm using pure javascript

replace $(window).height() with window.innerHeight

$(window).load(function(){    var w = window,    d = document,    e = d.documentElement,    g = d.getElementsByTagName('body')[0],    y = w.innerHeight|| e.clientHeight|| g.clientHeight;    console.log(y);});

Chrome :

jsfiddle : 667

my site : 667

Mozilla

jsfiddle : 602

my site :602

https://stackoverflow.com/a/11744120/1297435