Loading an SVG file with onload event handlers will not have those handlers invoked by either creating the node or appending it to the document. You are supposed to use document.importNode to import a node from one document to another. The responseXML is in another DOM document, and you can't normally just move nodes from one document to another. The solution is to use a real XHTML document where SVG-namespaced elements are actually treated as SVG. HTML is not XHTML, and support for SVG in HTML is shoddy and poorly-defined as of this writing. In general, the problem is twofold threefold: Presumably the answer is to get the script into the header? ![]() Tested on F/F, Opera, Chromium, but doesn't work anyway on (my) Chromium. If I edit Phrogz'z code to use the circle file (replace 'stirling4.svg' with the name of this file), then it works, but if I want the scripted rectangle instead, it doesn't. You should be able to view both directly in any browser, except IE8. The second is a scripted svg, displaying a rectangle. The first is a 'standard' simple svg, displaying a circle. In response to Phrogz'z answer below - I've added two simple svg files. I've also tried assigning the response to an innerHTML, but that does nothing. If I change 'responseXML' to 'responseText', then Opera/Chrome correctly display the entire svg text (not image) in the right place, and F/F still gives the same warning. ![]() Then Opera and Chrome do nothing, and F/F complains "". If I do this: // xmlhttp.onreadystatechange:ĪddImage(xmlhttp.responseXML, "somewhere") ĭocument.getElementById(dst_id).appendChild(scr) I can get the image text back into the browser, but I can't find a way to insert it into the DOM that will actually display it. I have some code that retrieves a scripted svg image from a server via Ajax.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |