SVG:Namespace: Difference between revisions

Jump to navigation Jump to search
Line 14: Line 14:
   
   
  </svg>
  </svg>
= use namespace aware methods in javascript=
when using js, make sure you use the namspace aware methods like
*getElementsByTagNameNS()
*createElementNS()
*setAttributeNS()
*getAttributeNS()
*...
svg elements are in the svg namespace. svg attributes are in the null namespace.
for example, to dynamicly create an <image> element, do it like this:
svgns="http://www.w3.org/2000/svg"
xlinkns="http://www.w3.org/1999/xlink">
newIM=document.createElementNS(svgns,"image")
newIM.setAttributeNS(null,"width",100)
newIM.setAttributeNS(null,"height",100)
newIM.setAttributeNS(xlinkns,"href","bild2.png")
73

edits

Navigation menu