Re: svg and javascript embedded in html
HelderMagalhaes <[email protected]> Fri, 4 Sep 2009 01:59:18 -0700 (PDT)
| Newsgroups | gmane.comp.mozilla.devel.svg |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <[email protected]> |
Hi mario,
> document = window.document.svg1.getSVGDocument();
> svgElement = document.getElementById("elementname");
There are several things I'd suggest differently:
1. Making an attribute to the "document" (special) variable may have
undesired results. Consider using another variable such as "svgEle";
2. Acessing the element's identifier though it's JavaScript variable
("document.svg1") is deprecated (there should be warnings in the Error
Console). You should use "document.getElementById" instead;
3. Best (only?) way to get a pointer to the SVG document's DOM in
Gecko is "CONTAINER_OBJECT_DOM.contentDocument" [1].
Summing up, you example would turn into:
svgDocument = document.getElementById("svg1").contentDocument;
svgElement = svgDocument.getElementById("elementname");
> But now I need to use also some of the Variables in the JavaScript
> part of the file. Is it possible to access them form the html(with
> javascript of course) file like it's possible with the svg part? Right
> now I'm putting all the values I need in a hidden Textnode and get
> them as every other svg node. But thats not very effectiv and looks
> ugly...
I've found this paragraph to be a little confusing. Please clear [2]
it up a if possible.
> thx for any help.
Hope this helps,
Helder
[1] http://jwatt.org/svg/demos/getSVGDocument.html
[2] http://www.catb.org/~esr/faqs/smart-questions.html#writewell