Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 10 years ago

#8048 closed bug (patchwelcome)

overflow:scroll gives wrong width in IE8

Reported by: [email protected] Owned by:
Priority: low Milestone: 1.next
Component: dimensions Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:


jQuery 1-4-4 Internet Explorer 8 vs. Firefox 3.6.6 Win 7 x64

When I have my <body> element set to overflow:scroll, IE 8 gives the same width as without a scrollbar, while Firefox returns different values for the width with and without the scrollbar.

    $('div').append('<p>' + $(document).width() + '</p>');
    $('div').append('<p>' + $(document).width() + '</p>');
    $('div').append('<p>' + $(document).width() + '</p>');


Will return in firefox: 834 817 817

Will return in IE 8: 834 834 834

JSFiddle can be found here: JSFiddle

Change History (6)

comment:1 Changed 12 years ago by jitter

Component: unfileddimensions
Priority: undecidedlow
Resolution: patchwelcome
Status: newclosed

Thanks for taking the time to contribute to the jQuery project by writing a bug report.

I'm not convinced that this is a bug.

From my investigations it seems that IE in this case returns a different value then most other browsers for offsetWidth. But afaik offsetWidth isn't standardized by a W3C spec but comes from the MSIE DHTML object model.

I also don't understand why you are checking $(document).width() when setting styles on the body. If you do $("body").width() you should get the expected results. You could also resort to manually checking the scrollWidth which also should give you the value you want.

In any case I guess this isn't trivial to fix (if it is a bug at all), thus I close this ticket.

If you can provide a detailed rundown on why this indeed is a bug and you have a small patch (as pull request) available please report back.

Related reading:





comment:2 Changed 12 years ago by [email protected]

Ok accepted, I did do some other tests as well. But the bodyWidth is indeed the best solution. I still find it strange that the document doesn't give a right value when overflow: scoll is on, because it is only in IE8 and not in IE7.

IE8 pretends if the scrollbar isn't there, but does adjust its body to it.

Thanks for the advice.

comment:3 Changed 12 years ago by jitter

#8345 is a duplicate of this ticket.

comment:4 Changed 11 years ago by anonymous

Please review this as this is still an issue...

comment:5 Changed 11 years ago by anonymous

Please reopen this as this is very much still an issue... Look below for details.


comment:6 Changed 10 years ago by mikesherov

#12653 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.