maxp
maxp

Reputation: 25151

Calculated width wrong in Chrome, fine in FFox / IE?

Very weird bug im experiencing.

When getting the width of a cell, in Chrome, using jQuery (or plain old javascript), it appears to blindly looks at the css width property, whereas firefox actually reports the rendered width.

Example shown here http://jsfiddle.net/Dg7cg/

Using Chrome: '30.0.1599.69 m', rendered output here: enter image description here

I'm expecting a value of around 107px, but Chrome seems to report 23px.

Does anyone know of a javascript function that will report the 'true' width from within chrome?

Upvotes: 2

Views: 1825

Answers (2)

Eric Seidel
Eric Seidel

Reputation: 56

This was an unintentional regression in Chrome which is tracked by https://code.google.com/p/chromium/issues/detail?id=290399

Upvotes: 4

fred02138
fred02138

Reputation: 3361

You can use

document.defaultView.getComputedStyle(elem)['width'];

On some browsers

document.getComputedStyle(elem)['width'];

will work.

Upvotes: 2

Related Questions