[Project_owners] Extracting external Style Sheet definitions from DOM

Matthew Wilson matthew at mjwilson.demon.co.uk
Tue Dec 7 20:12:25 EST 2004


Ingo Rau wrote:
> Hello!
> 
> My extension needs to extract some style sheet definitions from a webpage.
> If the webpage has
> <BODY style="background-image:url(file);">
> I can use obj.style.backgroundImage in JavaScript, no problem.
> 
> But if I have
> <BODY id="some_style">
> and an external CSS file with for example
> #some_style { background-image:url(file); }
> only obj.style.id is defined.
> 
> Of course, this makes sense, but I how do I get the CSS definition?

I imagine it's all in here:
http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html

> And is 
> there a difference between id and class?

All the difference in the world. An id uniquely identifies an element 
within a document. A class can be applied to many elements.

Matthew



More information about the Project_owners mailing list