On Mon, 19 Nov 2012 10:55:54 +0100, <[email protected]> wrote:
> Hi,
> personally, since it's possible in modern browsers, I would put the svg
> directly in html.
> And you can load and parse your file with an ajax call :
>
> var r = new XMLHttpRequest();
> r.open("GET", "myFile.svg",true);
> r.onreadystatechange = function () {
>
> if (this.readyState != 4 || this.status != 200) return;
>
> var parser = new DOMParser();
> var doc = parser.parseFromString( this.responseText, "image/svg+xml");
> var svg = doc.documentElement;
> document.getElementById("myHtmlContainer").appendChild(svg);
> };
> r.send();
You can also just use the XMLHttpRequest.responseXML attribute[1], then
you don't need to create a new DOMParser for parsing the result. For some
examples that work in all browsers see [2].
[1] http://www.w3.org/TR/XMLHttpRequest/#the-responsexml-attribute
[2] http://stackoverflow.com/a/7986519/109374
--
Erik Dahlstrom, Core Technology Developer, Opera Software
Co-Chair, W3C SVG Working Group
Personal blog: http://my.opera.com/macdev_ed
------------------------------------
-----
To unsubscribe send a message to: [email protected]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my
membership"
----Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/svg-developers/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/