Re: (DOM)Compute the sum of width of elements contained in blockleve element
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: (DOM)Compute the sum of width of elements contained in blockleve element

From: Thomas 'PointedEars' Lahn <PointedEars@web.de>
Date: Wed Feb 08 2006 - 16:05:15 CET

Thomas 'PointedEars' Lahn wrote:

> That is not quite correct.  getComputedStyle() as introduced in W3C DOM
> Level 2 Style returns (a reference to) a CSSStyleDeclaration object which
> does not have a `width' property nor does it have a namedItem() method to
> allow for this property access in ECMAScript implementations.  So the
> fully standards compliant DOM access would be
>
> getComputedStyle(objRef, pseudoElem).getPropertyValue("width")
>
> which is supported only in the Gecko DOM (where the global Window object
> appears to implement the ViewCSS interface). It should also be noted that
> of all the DOMs tested, the KHTML DOM (Konqueror, Safari), Version 3.5.1
> (Konqueror 3.5.1), does not appear to support any of the mentioned access
> methods.

My test case was flawed. Different to the `offsetWidth' property,
getComputedStyle() values are not (reliably) available in the Opera
and KHTML DOM before the document was fully loaded. When I appended
a text node with the retrieved value to the `body' element when its
`load' event fired, that text node contained the expected value.
So the support matrix is currently

                             Gecko IE Opera KHTML SC[0]
------------------------------------------------------------------ -----
getComputedStyle(objRef, [1], [2] - [4] [5] Yes
pseudoElem)
.getPropertyValue("width")

getComputedStyle(objRef, [1], [2] - [4] [5] Yes?
pseudoElem).width

objRef.offsetWidth [1], [2] 5.0+ [3] [4] [5] No

objRef.currentStyle.width - 5.0+ [3] - - No
------------------------------------------------------------------ -----

where objRef === document.body and pseudoElem === null.

It is Netscape 4.x --

Mozilla/4.8 [en] (X11; U; Linux 2.6.15.1-20060130.184242+0100 i686)

-- that supports neither access method mentioned.

PointedEars
___________
[0] Standards compliant; see quote for "Yes?"
[1] Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060205
      Debian/1.7.12-1.1
[2] Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8) Gecko/20060110
      Debian/1.5.dfsg-4 Firefox/1.5 Mnenhy/0.7.3.0
[3] Cannot test here, version information from MSDN Library
[4] Opera/8.51 (X11; Linux i686; U; en)
[5] Mozilla/5.0 (compatible; Konqueror/3.5;
      Linux 2.6.15.1-20060130.184242+0100; X11; i686; de, en_US)
      KHTML/3.5.1 (like Gecko) (Debian package 4:3.5.1-1)
Received on Mon May 1 03:10:15 2006