2010-07-29 46 views
3

我一直在玩动画的SVG找到流动的文本元素:无法通过ID在SVG

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); 
} 

它可以找到 '球' 罚款的对象,而不是 '调试' 对象(的getElementById返回null)。我可以在源代码中看到它,为什么脚本无法找到它?

回答

1

最有可能你在SVG 1.1的实现测试,如flowRoot在SVG推出1.2
无效的元素将被忽略,因此没有显示在DOM了