Re: JS, the DOM and CSS

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

 Date:  Sat, 18 May 2002 18:08:27 +0100
 To:  "Brett Errington" <brett(at)opensearch.com>,
<hwg-techniques(at)hwg.org>
 References:  brett
  todo: View Thread, Original
Many thanks for that -

I had a play, but the syntax i had i am sure is right -
Then  when i read the blurb in the book, it did mention that "this is not
yet well supported" - so i think i may be able to blame the browser
support - neither IE6 nor NS6 let it work "as the book says".

I got as far as i could and decided that i can;t do it -
I've been given code that loops through *all* the rules, looking for a
matching class name, so i'll use that - unless you can find a way to use a
named class to access the style properties (which would be much better :-))
!


thanks -

hilma
--x----





----- Original Message -----
From: "Brett Errington" <brett(at)opensearch.com>
To: <hwg-techniques(at)hwg.org>
Sent: Saturday, May 18, 2002 4:11 PM
Subject: RE: JS, the DOM and CSS


> Hi
>
> I've never tried to access the stylesheet like this but that's probably
> because I haven't had a need. Normally I access an object's (on the
> page) style like so:
>
> document.all['object_name'].style.color
>
> Therefore maybe you want to try something along the lines of:
>
> document.Sheets[0].style
>
> If your still stuck and no one else has the answer then I shall have a
> go myself. Otherwise try www.javascriptkit.com because they have lots of
> useful stuff on the DOM etc.
>
> Later,
> Mr Brett
>
> "That's a pain that will surely linger, and that's no lie"
> - Ed Grimely
> -----Original Message-----
> From: owner-hwg-techniques(at)hwg.org [mailto:owner-hwg-techniques(at)hwg.org]
> On Behalf Of Hilma
> Sent: Saturday, 18 May 2002 6:00 PM
> To: hwg-techniques(at)hwg.org
> Subject: JS, the DOM and CSS
>
> Hi -
> i hope someone can help on this one - and i hope i'm in the correct
> palce
> for it!
>
> I'm trying to find out, via JS, the value of particular property
> within a particular class, as defined in a style sheet;
> e.g. i want to know the width of anything that has class "NavButton",
> (where
> that
> class has the width defined in a .css)
>
> I've got as far as
> mySheet = document.Sheets[0]
>
> but when i try to access
> (1)   RuleCount = document.Sheets[0].cssRules.length
> or
> (2)  FirstRule= document.Sheets[0].cssRules[0]
> (and ultimately
> (3)  NavWidth = document.Sheets[0].cssRules['NavButton'].width)
>
> i come up with errors: "Not an object or is null".
>
>
> I think i'm using the syntax from my JS book, and i want it to work in
> IE6 and NS6; but cannot get further into the sheets array than
> discovering that it has one element :
>
> SheetCount = document.Sheets.length
>
> succesfully returns 1!
>
> Many thanks for any ideas -
>
>
> h.
>
>
>
>

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