Including JavaScript in SVG
Here is a working version as I would write it: <!DOCTYPE svg PUBLIC “-//W3C//DTD SVG 1.1//EN” “http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd”> <svg version=”1.1″ xmlns=”http://www.w3.org/2000/svg”> <circle cx=”250″ cy=”250″ r=”50″ fill=”red” /> <script type=”text/javascript”><![CDATA[ var KEY = { w:87, a:65, s:83, d:68 }; var moveSpeed = 5; var circle = document.getElementsByTagName(“circle”)[0]; var x = circle.getAttribute(‘cx’)*1, y = circle.getAttribute(‘cy’)*1; document.documentElement.addEventListener(‘keydown’,function(evt){ switch (evt.keyCode){ … Read more