views:

26

answers:

1

I've been playing with animation in an SVG: http://imgh.us/renamon-animtest.svg (links to script "anim.js")

In the window.onload event, I have:

function init(evt)
{
    if(window.svgDocument == null)
    {
        if(evt.target && evt.target.ownerDocument)
            svgDocument = evt.target.ownerDocument;
        else if(evt.originalTarget && evt.originalTarget.ownerDocument)
            svgDocument = evt.originalTarget.ownerDocument;
        else svgDocument = document;
    }

    _debug = svgDocument.getElementById('debug');
    alert(_debug.firstChild.nodeValue);

    for(i = 0; i < 1; i++)
        balls[i] = svgDocument.getElementById('ball' + i);
    setInterval(loop, 50);
}

It can find the 'ball' objects fine, but not the 'debug' object (getElementById returns null). I can see it in the source, so why can't the script find it?

A: 

Most likely you're testing in an implementation of SVG 1.1, as flowRoot was introduced in SVG 1.2
Invalid elements are ignored, therefore not showing up in the DOM

stelt