|
<?xml
version="1.0"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="200" height="100" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<title>Methoden zum Zugriff auf Text</title>
<defs>
<script type="text/ecmascript"><![CDATA[
function textdemo(evt) {
var svgdoc = evt.getTarget().getOwnerDocument();
var text = svgdoc.getElementById('text');
alert('Inhalt des
Text-Knotens: '+text.getFirstChild().getData()+
'\nLaenge
des Textes \"Hier klicken!\": '+text.getComputedTextLength()+'px'+
'\nLaenge
des Substrings \"Hier\": '+text.getSubStringLength(0,4));
}
]]>
</script>
</defs>
<g font-size="20" onclick="textdemo(evt)">
<rect x="0" y="0" width="100%"
height="100%" fill="#AAAAFF"/>
<ellipse cx="50%" cy="44%"
rx="60" ry="30" style="fill:#AA9999;stroke:white;stroke-width:2;"/>
<text id="text" x="50%"
y="50%" text-anchor="middle">Hier klicken!</text>
</g>
</svg> |
|