Previous Message
Next Message

[css-d] Re: Accessing CSS property values with JavaScript (was: RE: [css-d]

Sent by Ben Henick on 8 February 2002 16:04


On Fri, 8 Feb 2002, Porter Glendinning wrote:

> At 15:11 2/8/02, Ben Henick digitized these thoughts:
> >Writing the values is something I've never had trouble with.
> >
> >It's retrieving them that's the problem...
> [snip]
> >What am I doing wrong?
> 
> Nothing. This is, IMHO, one of the most developer-unfriendly aspects of 
> the current interaction between JavaScript and CSS. The only values 

So my message was even more on-topic than I originally suspected...

> that you can query directly from the element's style object are ones 
> that are actually set in the element's style property:
> 
>      <div style="visibility: hidden;">Can't see me</div>
> 
> Or ones that you've set explicitly with JavaScript:
> 
>      var hideMe = document.getElementById("hideMe");
>      hideMe.style.visibility = "hidden";

Ewww.  Egads.

>    * Write code to walk through all the stylesheet objects that apply to
>      the document looking for rules that could possibly apply to the
>      element I want to work with, which the browser already does in order
>      to render the page in the first place, and probably does a lot
>      better than I could with JavaScript anyway.
> 
> Each of these methods obviously has its problems. The first two would 
> work on a fairly small scale as a bandage, since we don't really have 
> much of a choice. But I wouldn't wish the third on anyone.

Hmmm...

You can retrieve the names of the classes and id's easily enough in both 
IE and Netscape 6.

But you're right, matching them with stylesheet rules would be a 
nightmare, and probably not worth the bandwidth you'd have to spend in 
order to get the evolution to work as intended in Gecko.

Damn.  Damn.  Damn.


-- 
Ben Henick
Web Author At-Large              Managing Editor
http://www.io.com/persist1/      http://www.digital-web.com/
[EMAIL-REMOVED]                  [EMAIL-REMOVED]
--
"Are you pondering what I'm pondering, Pinky?"
"I think so, Brain, but... (snort) no, no, it's too stupid."
"We will disguise ourselves as a cow."
"Oh!" (giggles) "That was it exactly!"
Previous Message
Next Message

Message thread: