W3C home > Mailing lists > Public > www-style@w3.org > May 2004

getComputedStyl, ViewCSS (and Safari)

From: Gavin Kistner <gavin@refinery.com>
Date: Tue, 25 May 2004 15:46:59 -0600
Message-Id: <0CC37DFE-AE95-11D8-8C0F-000A959CF5AC@refinery.com>
To: www-style@w3.org

According to the DOM 2 CSS specs, the ViewCSS class (which inherits  
from DOM2Views::AbstractView) has an instance method  
"getComputedStyle()". [1] I'm writing a function [2] in JS to get the  
current style of an element in a cross-browser manner. It works for  
IEWin and Mozilla, but not Safari (v1.2). Some questions:

* From the DOM 2 CSS specs, I see that the DOM2Views::DocumentView  
class has a defaultView property which points to an AbstractView  
instance. Mozilla uses document.defaultView to refer to the ViewCSS  
instance for getComputedStyle(), but in Safari 'document.defaultView'  
is a function that returns an AbstractView instance. Is Safari  
definitely wrong in this case?

* What is the second parameter ('pseudoElt') in getComputedStyle for?  
(The documentation for it [3] is really vague, saying only that it's a  
DOMString and describing it as "The pseudo-element or null if none.")

* Using document.defaultView().getComputedStyle(myEl,null) always  
returns null in Safari, even for elements with explicit styling on them  
[4]. Does anyone know if Safari is simply broken in this regards, or if  
there's a way to get the computed style for an element?

Thanks in advance for any answers you can help me out with.

(-, /\ \/ / /\/

[1] http://phrogz.net/ObjJob/object.asp?id=250
[2] http://phrogz.net/JS/CurrentStyle_js.txt
[4] http://phrogz.net/tmp/currentstyle.html
Received on Tuesday, 25 May 2004 17:47:32 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:13 UTC