firefox svg.getElementById('id') [英] firefox svg.getElementById('id')
问题描述
我试图检索路径:
document.getElementsByTagName('svg')[0] .getElementById('me')。setAttribute('d ',M 30 30 ...)
这在Chrome和Safari中工作正常,在Firefox中(我必须使用 getElementsByClassName(..)[0]
)是否有东西我缺少,或者是 id
作为属性不允许在一个svg文件?
顺便说一句我检查了火狐8.0的最后一个版本
$ b
如果这被表示为正常的脚本错误,会很好。 第一个评论(我使用ID的正确方法):组件返回失败代码:0x80004001(NS_ERROR_NOT_IMPLEMENTED)[nsIDOMSVGSVGElement.getElementById] $> c code
< svg xmlns =http://www.w3.org/2000/svgversion =1.1height =370 width =400baseProfile =fullviewbox =0 0 1000 1000>
< g stroke =blackstroke-width =8fill =blacktransform =scale(4)>
< / g>
< / svg>
Firefox中的svg.getElementById 。它会出现在Firefox 11中。
I'm experimenting with interactive images. I've a jquery-ui slider bound to a function which updates the path inside an svg document (embedded in a web page).
I'm trying to retrieve the path with:
document.getElementsByTagName('svg')[0].getElementById('me').setAttribute('d', "M 30 30 ...)
This is working fine in Chrome and Safari, but not in Firefox (where I have to use getElementsByClassName(..)[0]
. Is there something I'm missing, or is id
as attribute not allowed in an svg document?
BTW I checked on the last release of Firefox 8.0
Just saw now an message in the console:
Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIDOMSVGSVGElement.getElementById]
Would have been nice if this was indicated as a normal script error.
As per first comment (i'm using id's the proper way):
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="370" width="400" baseProfile="full" viewbox="0 0 1000 1000">
<g stroke="black" stroke-width="8" fill="black" transform="scale(4)">
<path id="me" d="" class="classme"/>
</g>
</svg>
I've just implemented svg.getElementById
in Firefox. It will appear in Firefox 11.
这篇关于firefox svg.getElementById('id')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!