SVG – Learning by Coding

[ Mozilla-DOM-Test_4.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 09/05 thomas@handmadecode.de     -->

​ 9: 10: 
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

​11: 12: 
  <title>SVG Learning by Coding</title>

13: 
  <desc>SVG-Spezifikation in Beispielen</desc>

​14: 15: 
  <defs>

​16: 17: 
    <script type="text/javascript">

18: 
      <![CDATA[

​19: 20: 
      var clk=true;

​21: 22: 
      function MozDOMTest4()

23: 
      {

24: 
        if(clk)

25: 
        {

26: 
          var svgobj=document.getElementById("gruppe"),xmlser,output;

27: 
          // gesamtes Dokument einbeziehen:

28: 
          // var svgobj=document;

​29: 30: 
          // Alternative fuer ASV mit Methode printNode():

​31: 32: 
          if(window.printNode)

33: 
          {

34: 
            output=printNode(svgobj);

35: 
            alert("Ergebnis:\n\n"+output);

36: 
          }

​37: 38: 
          else if((navigator.mimeTypes &&

39: 
                   navigator.mimeTypes["image/svg+xml"] &&

40: 
                   !navigator.mimeTypes["image/svg+xml"].enabledPlugin) ||

41: 
                   document.implementation.hasFeature("org.w3c.dom.svg","1.0"))

42: 
          {

43: 
            if(window.XMLSerializer)

44: 
            {

45: 
              xmlser=new XMLSerializer();

46: 
              output=xmlser.serializeToString(svgobj);

47: 
            }

48: 
            else output="Kein Ergebnis erhalten!";

​49: 50: 
            alert("Ergebnis:\n\n"+output);

51: 
            // ggf. serverseitige Weiterverarbeitung von output, z. B. via POST:

52: 
            // XMLHttpRequest() unter Mozilla/Firefox oder postURL() im ASV

53: 
          }

54: 
          else alert("Keine SVG-Implementierung\nauf Mozilla-Basis gefunden!");

55: 
        }

56: 
        else alert("Der Test wurde bereits ausgeführt!");

57: 
      }

​58: 59: 
      ]]>

60: 
    </script>

​61: 62: 
  </defs>

​63: 64: 
  <text x="20" y="30" style="fill: #000; font-size: 24px">

65: 
    Mozilla-DOMSVG-Inhalte serialisieren</text>

​66: 67: 
  <a xlink:href="" cursor="pointer" onclick="return false"><text x="20" y="60" style="fill: #F00; font-size: 14px"

68: 
    onclick="MozDOMTest4();clk=false">Test ausführen!</text></a>

​69: 70: 
  <g id="gruppe">

71: 
    <rect x="20" y="80" width="100" height="50" fill="#F00"/>

72: 
    <circle cx="160" cy="105" r="25" fill="#090" onclick="Test();clk=false"/>

73: 
    <text x="200" y="110" fill="#00C" font-size="12px">Beispieltext</text>

74: 
  </g>

​75: 76: 
</svg>

[zum Anfang]