Hi I’m starting using SVG with javaScript, I have a page that contains a embedded SVG and I use JavaScript to manipulate it, but when the page onload it shows an error “undefined” is null or isn’t an object, and I don’t know why, I hope you can help me thanks.
Note: I change the “<” “>” for “(” “)”
This is the svg code
(?xml version=“1.0” encoding=“utf-8”?)
(!-- Generator: Adobe Illustrator 12.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 51448) --)
(!DOCTYPE svg PUBLIC “-//W3C//DTD SVG 1.1//EN” “http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd” [
(!ENTITY ns_svg "http://www.w3.org/2000/svg ")
(!ENTITY ns_xlink "http://www.w3.org/1999/xlink")
) (svg version="1.1" xmlns=" http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="806" height="606" onload="inicio(evt)")
(/svg)
and the JavaScript in the HTML
(!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”)
(html)
(head)
(script language=“JavaScript” type=“text/javascript”)
var svgDocument=null;
var eventos=null;
var contador=new Array(6);
var form;
function inicio(evt)
{
evento = evt.getTarget(); //Here it marks the mistake
if(evento!= null)
{
svgDocument=evento.getOwnerDocument();
svgRoot= svgDocument.documentElement;
}
else
alert("null");
}
…
(/html)