Discussion:
problem with dynamic tags created via javascript in mozilla
(too old to reply)
slash12
2006-01-11 17:17:57 UTC
Permalink
We've written an image annotation tool that allows you to annotate an
image, drawing arrows, circles, lines, and text on top of the image.
So we have event handlers that create new tags, that identify these new
elements on the fly, and insert them into the SVG DOM via javascript as
the user clicks on the picture.

This doesn't seem to be working in mozilla's SVG, however it does work
in IE using adobe's plugin. If I try to grab an element already in the
DOM, and make changes to it's attributes, this works fine, I just can't
seem to get new elements created in the DOM via javascript to show up.
Any ideas on ways that I can create these new elements so that they
show up in mozilla?

here's a little snippet of some of what I'm doing that doesn't seem to
be working:




var svgDocument = document.getElementById(embedID).getSVGDocument();
var w = svgDocument.createElement("circle");
w.setAttribute("type","circle");
w.setAttribute("cx",cx);
w.setAttribute("cy",cy);
w.setAttribute("r",r);
w.setAttribute("stroke",stroke);
w.setAttribute("stroke-width",strokeWidth);
w.setAttribute("fill","none");
svgDocument.rootElement.appendChild(w)
Christian Biesinger
2006-01-11 22:32:55 UTC
Permalink
Post by slash12
var svgDocument = document.getElementById(embedID).getSVGDocument();
var w = svgDocument.createElement("circle");
See http://developer.mozilla.org/en/docs/SVG:Namespaces_Crash_Course,
especially this part:
http://developer.mozilla.org/en/docs/SVG:Namespaces_Crash_Course#Scripting_in_Namespaced_XML
slash12
2006-01-12 15:05:22 UTC
Permalink
awesome! this was indeed the problem, thanks.

Loading...