You might be able to lift some ideas from this code out of my libraries
I use for CSS, although it's not the way I currently do it owing to
issues with
the Opera browser. For that I have a server side PHP class that parses the
CSS file and can be used to output a javascript object reflecting the
CSS values
function DCgetCSSclass(oD,szCSS,szLeadin)
{
if(typeof szLeadin=='undefined' )szLeadin=".";
if(!szCSS )
return { DCerror:"null classname:"+szCSS}
oCSSrules =null;
if((typeof oD.styleSheets)!="undefined")
{
for(xx=oD.styleSheets.length-1;xx>=0;xx--)
{
if(typeof oD.styleSheets[xx].cssRules
!="undefined")oCSSrules=oD.styleSheets[xx].cssRules
if(oCSSrules)
for(yy=0;yy<oCSSrules.length;yy++)
if(typeof ( oCSSrules.item(yy).selectorText!="undefined"))
if(
oCSSrules.item(yy).selectorText.toLowerCase()==szLeadin+szCSS.toLowerCase()){
return oCSSrules.item(yy).style}
}
}else{
//alert("MooCSS")
}
if(typeof oD.classes !="undefined")
if(typeof oD.classes[szCSS]!="undefined")
return oD.classes[szCSS].all;
if(typeof self.oDCfauxCSS!='undefined')
{
for(i in self.oDCfauxCSS)if(i == szCSS)
{
oCSSresult=eval("self.oDCfauxCSS."+i)
return oCSSresult;
}
}
oR={ DCerror:"class not found:"+szCSS}
return oR;
}
todaius2003 wrote:
> Hi,
>
> I would like to know how to read a value of a property in a css class
> from svg using javascript.
>
> Specifically, I would like to retrieve the font-size of the text
> element in the following example.
>
> This example includes two files: svg file, and a css file that the
> svg file refers to.
>
> Thanks,
> vn1977
>
> //*********************svg file*******************************
> <?xml version="1.0" standalone="no"?>
> <?xml-stylesheet href="commonMap.css" type="text/css"?>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG
> 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
>
> <svg id="mainMap" width="950" height="475"
> viewBox="-82.049332 -30.5758 0.667485000000013
> 0.471659000000002"
> xmlns:xlink="http://www.w3.org/1999/xlink">
>
> <script language="text/ecmascript" >
> <![CDATA[
> ]]>
> </script>
> <text x="="-81.9332 " y="-30.2758"
> class ="FreewayText" >
> Hello, out there
> </text>
> </svg>
> //*******************end of svg file*************************
>
> ===================================================
> //*****************commonMap.css
> file***************************************
> *.FreewayText
> {
> text-anchor: middle;
> font-family:Verdana;
> font-size: 0.001;
> color: black;
> }
> //***************end of css file********************************
>
>
>
> -----
> To unsubscribe send a message to: [EMAIL PROTECTED]
> -or-
> visit http://groups.yahoo.com/group/svg-developers and click "edit my
> membership"
> ----
> Yahoo! Groups Links
>
>
>
>
>
-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my
membership"
----
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/svg-developers/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/