SVG – Learning by Coding

[ getbbox.svg --> Grafik anzeigen ]

 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: <!--    AuthorDrThomas 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:   onload="getSVGDoc(evt)">
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:       var svgdoc,svgroot;
22: 
23: 			
24:       function getSVGDoc(load_evt)
25:       {
26:         svgdoc=load_evt.target.ownerDocument;
27:         svgroot=svgdoc.documentElement;
28:       }
29: 
30: 
31:       function getBB()
32:       {
33:         var svgbox,b,h,x,y;
34: 
35:         svgbox=svgroot.getBBox();
36:         b=svgbox.width;
37:         h=svgbox.height;
38:         x=svgbox.x;
39:         y=svgbox.y;
40: 
41:         alert("Breite: "+b+"\nHoehe: "+h+"\nBox_x: "+x+"\nBox_y: "+y);
42:       }
43: 
44:       ]]>
45:     </script>
46: 
47:   </defs>
48: 
49:   <text x="20" y="30" style="fill: #000; font-size: 24px">
50:     DOM-Methode getBBox()</text>
51: 
52:   <a xlink:href="" cursor="pointer" onclick="return false">
53:     <text x="30" y="60" style="fill: #F00; font-size: 14px"
54:       onclick="getBB()">Grafikparameter abfragen
55:     </text>
56:   </a>
57: 
58: </svg>

[zum Anfang]