#12310 closed bug (wontfix)
$(window).height() and .width() do not work in IE6 and IE7
Reported by: | ebradsha | Owned by: | ebradsha |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | dimensions | Version: | 1.8.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I originally opened a ticket for this issue under #12300. However, it was prematurely closed out as 'worksforme' and I do not have the ability to re-open the bug.
Using $(window).width() and $(window).height() previously worked correctly with jQuery <1.8.0. In version 1.8.0, a value of 0 is always returned.
I have produced this bug under IE6 and IE7, I have not tested on other versions of IE.
I have tested this on multiple machines running IE6 and IE7 at multiple client sites with the same result every time. Unlike dmethvin, I do not have access to BrowserStack so I cannot speculate why the code worked on BrowserStack for him.
Here is a screenshot demonstrating the bug: http://s16.postimage.org/6zvnkd6r9/jquery_window_width_bug.png
Please let me know if you require any further demonstration of this bug to pursue debugging. I would be more than happy to grant a jQuery team member access to a VM running IE6 or IE7 so they can see this bug in action for themselves.
Change History (18)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Owner: | set to ebradsha |
---|---|
Status: | new → pending |
comment:3 Changed 10 years ago by
Status: | pending → new |
---|
You can take out the defer, the bug remains. I put in the defer so the body text would load before the alert came up. Would you like me to post a new screenshot?
comment:4 Changed 10 years ago by
Status: | new → pending |
---|
Please come up with a test case and stick to it.
comment:5 Changed 10 years ago by
Status: | pending → new |
---|
Here is the new screenshot:
http://s9.postimage.org/fuwrmbmgf/jquery_window_width_bug_no_defer.png
I'd be more than happy to grant you access to a dev VM running this test. Do you have a support/bugs email address I could send the login info to?
comment:6 Changed 10 years ago by
Status: | new → pending |
---|
We have to be able to repro it, otherwise we can't create a unit test against it. To simplify recreating the problem and to be sure we're looking at the same code, can you post that page somewhere?
comment:7 Changed 10 years ago by
Status: | pending → new |
---|
Here's an uploaded version, I added .height() in there as well:
comment:8 Changed 10 years ago by
Screenshot of my results from the online version:
http://s15.postimage.org/hg24bmrzv/jquery_bug_online_example.png
comment:9 Changed 10 years ago by
I'm seeing this behavior in IE9 as well. Calling $(window).width() or $(window).height() with jQuery 1.8 returns 0. Using "document" instead of "window" works as expected, though.
comment:10 Changed 10 years ago by
Component: | unfiled → dimensions |
---|---|
Milestone: | None → 1.next |
Priority: | undecided → low |
Status: | new → open |
comment:11 Changed 10 years ago by
This appears to have been broken by Pull Request https://github.com/jquery/jquery/pull/764 when a change was made to the dimensions.js file
There used to be a fallback check for the clientWidth off of the body, but that was taken out
Before Pull Request:
if ( jQuery.isWindow( elem ) ) { // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat doc = elem.document; docElemProp = doc.documentElement[ clientProp ]; return jQuery.support.boxModel && docElemProp || doc.body && doc.body[ clientProp ] || docElemProp; }
After Pull Request:
if ( jQuery.isWindow( elem ) ) { // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there // isn't a whole lot we can do. See pull request at this URL for discussion: // https://github.com/jquery/jquery/pull/764 return elem.document.documentElement[ clientProp ]; }
If we add back in the fallback for the body check it fixes IE9. I've tested locally using the above JSBin that Timmy made with a tunnel to my localmachine with the updated code.
Proposed Slightly Reverted Code:
if ( jQuery.isWindow( elem ) ) { doc = elem.document; return doc.documentElement[ "client" + name ] || doc.body && doc.body[ "client" + name ]; }
The trick is to know if this fix still addresses whatever was the intention of the Pull Request made 3 months ago. Seeing that how difficult this was to recreate the issue, I'm not sure how easy it will be to create a unit test showing that this fails inside our normal qunit test module.
I'll try to see if I can recreate the issue in a unit test within our existing qunit test suite and see if the above proposed fix addresses the original issue that was being addressed in the previous Pull Request.
comment:12 Changed 10 years ago by
That was me by the way... didn't realize I wasn't logged into the system ;)
comment:13 Changed 10 years ago by
Resolution: | → wontfix |
---|---|
Status: | open → closed |
comment:14 Changed 10 years ago by
Keywords: | needsdocs added |
---|
We need to redocument our lack of quirks mode support.
comment:15 Changed 10 years ago by
Keywords: | needsdocs removed |
---|---|
Resolution: | wontfix |
Status: | closed → reopened |
sorry, I missed the part where this wasn't quirks mode.
comment:16 Changed 10 years ago by
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
Actually, it is quirks mode!
http://stackoverflow.com/questions/69828/must-doctype-be-the-very-first-tag-in-an-html-document
Apparently, jsbin renderes everything in Quirks Mode?!?
<script>setInterval=setTimeout;</script><!DOCTYPE html>
comment:17 Changed 10 years ago by
Remi just fixed JSBin, and the JSBin example no longer exhibits this issue.
https://github.com/remy/jsbin/issues/312#issuecomment-7772785
Won't fix it stays.
comment:18 Changed 10 years ago by
$(window).height() returns 0 in IE 10. for time being I am using $(document).height()
You weren't giving us complete information. Your test cases don't match what you have in the screen shot.
script defer
is unfixably unreliable in IE. There's not even a reason to use it the way you do in the test case.https://github.com/h5bp/lazyweb-requests/issues/42
Can I close this now, or do you want to propose a solution of some kind after thoroughly reading the link above?