Re: JS, the DOM and CSS

by "Hilma" <Hilma(at)hilma.freeserve.co.uk>

 Date:  Mon, 20 May 2002 07:02:21 +0100
 To:  "Peter-Paul Koch" <gassinaumasis(at)hotmail.com>,
<hwg-techniques(at)hwg.org>
 References:  hotmail
  todo: View Thread, Original
>
> See http://www.xs4all.nl/~ppk/js/index.html?changess.html for everything
you
> need to know.

oh, look good, thank you :-)


> >I've got as far as
> >mySheet = document.Sheets[0]
..
> document.styleSheets[0]
> >(1)   RuleCount = document.Sheets[0].cssRules.length
> >(2)  FirstRule= document.Sheets[0].cssRules[0]

> These are both correct if you use document.styleSheets[0]

Thank you for that -  i can;t believe i spent ages over this and finally
wrote to the list for the sake of a misread page and a typo :-(
I am feeling suitably stupid !

> >(and ultimately
> >(3)  NavWidth = document.Sheets[0].cssRules['NavButton'].width)
>
> Nope, this one doesn't work. cssRules[] is not an associative array, it
> seems to have occurred to neither W3C nor the browser vendors to make it
> one, and you always need cssRules[].style.something

oh - bother!
That has, however,  saved me me a lot of time as i would have assumed that
indexing with a rule name would have worked.
Presumably, the rules are indexed in the sequence in which they occur (no
need to answer that, i'll experiment) - but it does seem very strange -
surely it's *obvious* we'd want to access these things by name?

Many thanks, and apologies for asking a simple typo question!

Hilma
--x-----

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA