Andrew Poulos wrote:
> On 12/02/2012 1:21 AM, Thomas 'PointedEars' Lahn wrote:
>> Thomas 'PointedEars' Lahn wrote:
>>> Andrew Poulos wrote:
>>>> I think you are misleading me as it doesn't look like there's a better
>>>> way.
>>> Wrong on both accounts. For crying out loud, a *closely related*
>>> question has been asked (presumably, *again*) on StackOverflow
>>> *yesterday*, and I
>
> So, I don't normally read StackOverflow.
OMG. Google is your friend!
> 1.
> document.defaultView.getComputedStyle(el,
> null).getPropertyValue("background-color")
Standards-compliant.
> 2.
> document.defaultView.getComputedStyle(el, null)["backgroundColor"]
>
> 3. document.defaultView.getComputedStyle(el,
> null).getPropertyValue("backgroundColor")
Not standards-compliant, not supposed to work.
> 4.
> document.defaultView.getComputedStyle(el, null)["background-color"]
Not standards-compliant, not supposed to work.
> 5.
> el.currentStyle["background-color"]
MSHTML-proprietary, but not supposed to work this way.
> 6.
> el.currentStyle["backgroundColor"]
MSHTML-proprietary; supposed to work *there*.
> where 'el' is a DIV with a bg colour set and this is what I got:
>
> IE 9
> ----
> 1. correct colour
> 2. correct colour
> 3. ""
All as expected.
> 4. correct colour
> 5. correct colour
Both unexpected, but then again I never waste time testing *wrong*
approaches.
> 6. correct colour
As expected.
> Opera 11.61
> -----------
> 1. correct colour
> 2. correct colour
> 3. ""
> 4. undefined
> 5. undefined
> 6. correct colour
All as expected. Opera has a long history of emulating MSHTML while trying
to be standards-compliant at the same time.
> Safari 5.1.2
> ------------
> 1. correct colour
> 2. correct colour
> 3. null
> 4. correct colour
All as expected.
> 5. error
> 6. error
Of course it gives an error in WebCore. It's MSHTML-proprietary, for
goodness' sake!
> Firefox 10.0.1
> --------------
> 1. correct colour
> 2. correct colour
> 3. ""
> 4. undefined
All as expected.
> 5. error
> 6. error
See above. However, you have neglected to test potential differences
between Standards Compliance and Quirks Mode in all cases. It is possible
that `currentStyle' is available in Gecko's Quirks Mode as is
`document.all'.
> Chrome 17.0.963.46
> ------------------
> 1. correct colour
> 2. correct colour
> 3. null
> 4. correct colour
> 5. error
> 6. error
Chrome's/Chromium's layout engine is (based on) WebCore. See above.
> 1 and 2 appear to be the most consistent.
Few surprises (t)here.
> Thanks for the time you spent helping me on this.
Hm, hm.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann