SVG – Learning by Coding
1: <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
2: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
3: "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
4: <!ATTLIST svg xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">
5: ]>
6:
7: <!-- SVG - Learning by Coding - http://www.datenverdrahten.de/svglbc/ -->
8: <!-- Author: Dr. Thomas Meinike 03/03 - thomas@handmadecode.de -->
9:
10: <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
11: id="aussen">
12:
13: <title>SVG - Learning by Coding</title>
14: <desc>SVG-Spezifikation in Beispielen</desc>
15:
16: <defs>
17:
18: <script type="text/javascript">
19: <![CDATA[
20:
21: function checkObj(click_evt)
22: {
23: var objekt;
24:
25: // inneres SVG-Objekt
26: objekt=click_evt.target.parentNode;
27: alert("Tagname: "+objekt.tagName+"\nID: "+objekt.getId());
28:
29: // aeusseres SVG-Objekt (Root-Objekt)
30: objekt=click_evt.target.ownerDocument.documentElement;
31: //oder click_evt.target.ownerDocument.rootElement;
32: alert("Tagname: "+objekt.tagName+"\nID: "+objekt.getId());
33: }
34:
35: ]]>
36: </script>
37:
38: </defs>
39:
40: <text x="20" y="30" style="fill: #000; font-size: 24px">
41: SVG in SVG verschachteln</text>
42:
43: <rect x="20" y="50" width="300" height="200"
44: style="fill: #EEE; stroke: #000; stroke-width: 2px"/>
45:
46: <svg id="innen">
47: <rect x="40" y="70" width="150" height="80"
48: style="fill: #FFC; stroke: #00C; stroke-width: 2px" onclick="checkObj(evt)"/>
49: <text x="40" y="170">Kleines Rechteck anklicken!</text>
50: </svg>
51:
52: </svg>
[zum Anfang]