firefox svg.getElementById('id') [英] firefox svg.getElementById('id')

查看:238
本文介绍了firefox svg.getElementById('id')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试验交互式图像。我有一个jquery-ui滑块绑定到一个函数,更新svg文档(嵌入在网页中)的路径。



我试图检索路径:

  document.getElementsByTagName('svg')[0] .getElementById('me')。setAttribute('d ',M 30 30 ...)

这在Chrome和Safari中工作正常,在Firefox中(我必须使用 getElementsByClassName(..)[0] )是否有东西我缺少,或者是 id 作为属性不允许在一个svg文件?



顺便说一句我检查了火狐8.0的最后一个版本


$ b

组件返回失败代码:0x80004001(NS_ERROR_NOT_IMPLEMENTED)[nsIDOMSVGSVGElement.getElementById] c code

如果这被表示为正常的脚本错误,会很好。



第一个评论(我使用ID的正确方法):



 < 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆