#12388 closed bug (invalid)
$(window).height() returns actually HTML document height in Firefox
Reported by: | Owned by: | mikesherov | |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | dimensions | Version: | 1.8.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Hello and thanks for the good work you do !
I recently experienced a serious issue when I passed from jq1.6.2 to jq1.8.0.
The simple fact of getting jq 1.8.0 made $(window).height() return actually my HTML document height which is quite bad for some of my positionning calculations.
So now basically $(window).height() behaves the same way than $(document).height.
The issue appears in following browsers :
- Google Chrome 21.0.1180.83 m
- Firefox 14.0.1
It doesn't show in IE9... here it is still fine.
I'm on Windows and use a WAMP local server.
To reproduce, I would simply do this : <script> Get the page height and width var winH = $(window).height(); var winW = $(window).width(); var docH = $(document).height(); var docW = $(document).width(); alert ("winH=" + winH + " winW=" + winW + " docH=" + docH + " docW=" + docW); </script>
Hope this helps...
Regards, Laurent Jager
Change History (20)
comment:1 Changed 11 years ago by
Component: | unfiled → dimensions |
---|---|
Owner: | set to [email protected]… |
Priority: | undecided → low |
Status: | new → pending |
comment:2 Changed 11 years ago by
Status: | pending → new |
---|
Hello,
I use $(window).height() to calculate the position of my modal windows so that they appear centered.
When I saw the issue, my HTML document was larger in height than my view window. The $(window) height was larger than expected as it was equal to the $(document) height.
I'll try do a test using a smaller HTML page of my site that completely fits inside the window height to check if it still returns the $(document) height.
So now to simply answer your question, I expected the window height to be smaller than the document height.
Regards, Laurent
comment:3 Changed 11 years ago by
Hello,
Further precisions... I tried with jq v1.7.2 and the issue does NOT appear... so this behavior is quite new...
As I mentionned I made a test with a smaller HTML page and the result shows that in this case the $(document).height() command returns the visible area of the page in Firefox but $(window).height() only returns the height of the part of the screen where there is actually visible HTML code.
I put 2 screenshots here : http://www.troovi.com/jfh22bjDVHLz (didn't know how to share this with you otherwise...) One with the small page and the other with the big page.
Each time I triggered an alert to display : $(window).height(), $(window).width(), $(document).height(), $(document).width().
My screen resolution is 1600x900.
Feel free to ask if you have any question !
Regards, Laurent
comment:4 Changed 11 years ago by
Status: | new → pending |
---|
Hi Laurent,
We introduced a new behavior in 1.7.2, and it broke a lot of people's expectations, so we reverted in 1.8. Can you please test one more time with 1.7.1?
If the behavior between 1.7.1 and 1.8.0 is consistent, I'm afraid there isn't much we can do here without a hosted reproducible test case, preferably on on jsfiddle.net or jsbin.com. Can you do that?
Thanks!
comment:5 Changed 11 years ago by
Status: | pending → new |
---|
Hello,
I tried with 1.7.1 and the issue still does not show. So it looks like it is only 1.8.0 related...
I was not able to reproduce with jsfiddle. I guess the $(window) object in jsfiddle is kind of simulated or something like that which prevents from reproducing. So I sent you a zip file containing a few html that was able to reproduce under Firefox.
Here it is : http://www.filedropper.com/jquerycoreticket12388
Surprisingly with this little piece of html I'm not able to reproduce with Chrome but I still see the issue on my development platform with Chrome.
Anyway, I hope it will a least give you a way to see the bug in action...
Regards, Laurent
comment:6 Changed 11 years ago by
Owner: | changed from [email protected]… to mikesherov |
---|---|
Status: | new → assigned |
Great, I'll investigate!
comment:7 Changed 11 years ago by
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
The problem here is that your document is rendering in quirks mode, which jQuery doesn't support and removed support for in 1.8. The top of your document looks like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
when it should look like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
or like this:
<!DOCTYPE HTML>
http://docs.jquery.com/Won't_Fix#Quirks_Mode
You'll see that if you render in standards mode that several other weird bugs you were experiencing go away. Thanks again for submitting the bug report!
comment:8 Changed 11 years ago by
Hello !
You're right... that solves the issue... I must admit it would have been quite a long way for me to find it out... (I guess I should read JQuery doc & release note more often... sorry for that !)
Just one last question... should I consider going to 'strict' mode ? I have a lot of legacy code that I would have to inspect for that so just to know if there are some more deadlines foreseen regarding 'loose' html support...
So thanks a lot for your support !
Best regards, Laurent
comment:9 Changed 11 years ago by
I would consider going to the html5 doctype declaration: <!DOCTYPE HTML>
as that is the latest doctype declaration.
I have no problem answering your questions, but please ask for further help on the forums or stackoverflow as this bug tracker is reserved for discussions about bug reports and not for support.
Thanks again!
Hi Laurent,
Thanks for the report. I need a little bit more info to see what's going on here. Can you provide me with the results of your test case and compare them with what you expected to see? Id like to know if you expected window height to be larger or smaller or document height to be larger or smaller.
Thanks again!