Skip to main content

Bug Tracker

Side navigation

#12388 closed bug (invalid)

Opened August 24, 2012 11:40AM UTC

Closed August 25, 2012 02:53PM UTC

Last modified July 28, 2013 04:41PM UTC

$(window).height() returns actually HTML document height in Firefox

Reported by: mickmail@yahoo.com 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

Attachments (0)
Change History (20)

Changed August 24, 2012 12:15PM UTC by mikesherov comment:1

component: unfileddimensions
owner: → mickmail@yahoo.com
priority: undecidedlow
status: newpending

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!

Changed August 24, 2012 12:52PM UTC by mickmail@yahoo.com comment:2

status: pendingnew

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

Changed August 24, 2012 05:09PM UTC by mickmail@yahoo.com comment:3

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

Changed August 24, 2012 06:50PM UTC by mikesherov comment:4

status: newpending

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!

Changed August 25, 2012 09:27AM UTC by mickmail@yahoo.com comment:5

status: pendingnew

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

Changed August 25, 2012 12:35PM UTC by mikesherov comment:6

owner: mickmail@yahoo.commikesherov
status: newassigned

Great, I'll investigate!

Changed August 25, 2012 02:53PM UTC by mikesherov comment:7

resolution: → invalid
status: assignedclosed

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!

Changed August 25, 2012 03:37PM UTC by mickmail@yahoo.com comment:8

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

Changed August 25, 2012 03:46PM UTC by mikesherov comment:9

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!

Changed September 03, 2012 04:15PM UTC by dmethvin comment:10

#12446 is a duplicate of this ticket.

Changed September 14, 2012 02:18PM UTC by dmethvin comment:11

#12540 is a duplicate of this ticket.

Changed September 19, 2012 02:07PM UTC by dmethvin comment:12

#12568 is a duplicate of this ticket.

Changed September 23, 2012 02:22PM UTC by mikesherov comment:13

#12585 is a duplicate of this ticket.

Changed September 27, 2012 01:42AM UTC by dmethvin comment:14

#12618 is a duplicate of this ticket.

Changed January 11, 2013 02:34PM UTC by dmethvin comment:15

#13192 is a duplicate of this ticket.

Changed February 15, 2013 05:34PM UTC by dmethvin comment:16

#13443 is a duplicate of this ticket.

Changed March 08, 2013 02:12PM UTC by dmethvin comment:17

#13585 is a duplicate of this ticket.

Changed March 20, 2013 02:31PM UTC by dmethvin comment:18

#13636 is a duplicate of this ticket.

Changed May 03, 2013 05:55PM UTC by dmethvin comment:19

#13852 is a duplicate of this ticket.

Changed July 28, 2013 04:41PM UTC by dmethvin comment:20

#14192 is a duplicate of this ticket.