S
Stephen Poley
I have been trying to do something which should be quite simple: write a
cross-browser script which, as part of its function, involves finding
what the displayed width of a table cell is.
After several hours of Googling and trying test pages, I'm baffled.
Lots of webpages claim that one uses OffsetWidth. However this does not
return the width: it appears to return width+padding+border. Microsoft's
own documentation claims that IE does indeed return the width in
standards mode, but I've tested it and it doesn't (at least for table
cells). Opera and Firefox appear in this respect to be bug-compatible
with IE.
The style.width property is useless unless the width has been set
explicitly on this element. Similarly for currentStyle["width"].
Firefox provides the decidedly baroque
document.defaultView.getComputedStyle(x, "").getPropertyValue("width")
which seems to work. Opera recognises it, but provides the same broken
result as OffsetWidth. IE does not support this method.
How can one get hold of this rather elementary piece of information in
browsers other than Firefox/Mozilla?
cross-browser script which, as part of its function, involves finding
what the displayed width of a table cell is.
After several hours of Googling and trying test pages, I'm baffled.
Lots of webpages claim that one uses OffsetWidth. However this does not
return the width: it appears to return width+padding+border. Microsoft's
own documentation claims that IE does indeed return the width in
standards mode, but I've tested it and it doesn't (at least for table
cells). Opera and Firefox appear in this respect to be bug-compatible
with IE.
The style.width property is useless unless the width has been set
explicitly on this element. Similarly for currentStyle["width"].
Firefox provides the decidedly baroque
document.defaultView.getComputedStyle(x, "").getPropertyValue("width")
which seems to work. Opera recognises it, but provides the same broken
result as OffsetWidth. IE does not support this method.
How can one get hold of this rather elementary piece of information in
browsers other than Firefox/Mozilla?