Forum Moderators: open
Does anyone have an example or a tip for me on how I can change attributes of part of an inline SVG?
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg">
<body>
<svg:svg viewBox="0 0 100 100">
<svg:circle id="foo" cx="50%" cy="50%" r="15%" fill="blue" />
</svg:svg>
<script type="text/javascript"><![CDATA[
document.getElementById("foo").setAttributeNS(null, "fill", "red");
]]></script>
</body>
</html>
Works in Firefox 2, Opera 9 and should work in Safari 3.
Thanks a lot for that. I'm going to have a lot of fun with SVG scripting :) From what I can see, if I can script inline SVG well I should be able to remove Flash from most of my sites for supported browsers.