2

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?

maxp
  • 24,209
  • 39
  • 123
  • 201
  • 1
    Worth looking at this: http://stackoverflow.com/questions/12212608/why-is-my-table-cell-width-wrong-in-chrome - may even be a duplicate, but I am not so sure about the solution. – Gray Oct 07 '13 at 14:49

2 Answers2

4

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

2

You can use

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

On some browsers

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

will work.

fred02138
  • 3,323
  • 1
  • 14
  • 17