SVG 在ASV 和 FF的兼容性说明

阅读更多
1.使用名字空间敏感的DOM方法
      DOM Level 1推荐标准在XML标准中出现名字空间之前发布,因此DOM1不是名字空间敏感的。这就引发了名字空间化XML中的问题,例如SVG。为解决这些问题,DOM Level 2核心添加了与DOM Level 1 对等的,但是名字空间敏感的方法。编写SVG时应使用名字空间敏感的方法。下表列出了不应再使用的DOM Level 1 方法以及与之对应的并推荐使用的DOM2方法。

DOM1 (不再使用)
  
DOM2 (推荐使用)
createAttribute
createAttributeNS

createElement  
createElementNS

getAttributeNode  
getAttributeNodeNS

getAttribute  
getAttributeNS

getElementsByTagName  
getElementsByTagNameNS (也应用在元素上)

getNamedItem  
getNamedItemNS

hasAttribute  
hasAttributeNS

removeAttribute  
removeAttributeNS

removeNamedItem  
removeNamedItemNS

setAttribute  
setAttributeNS

setAttributeNode  
setAttributeNodeNS

setNamedItem  
setNamedItemNS

      所有DOM2名字空间敏感方法的第一个参数必须是所操作元素或属性的“名字空间名称”。对SVG元素是“http://www.w3.org/2000 /svg”,然而,请注意:XML 1.1推荐标准中的名字空间规定,不带前缀属性的名字空间名称为空。也就是说,对SVG属性必须使用null名字空间。
因此,使用 createElementNS创建一个SVG “rect”元素必须写为:
        createElementNS('http://www.w3.org/2000/svg', 'rect');
然而取得该“rect”元素中的“x”属性值必须写为:
        getAttributeNS(null, 'x');
注意对其它(非SVG)名字空间的属性并不适用。例如xlink:href使用了一个名字空间前缀,因为存在一个名字空间前缀标记(xlink),名字空间名称为前缀的值即http://www.w3.org/1999/xlink,因此取得元素中xlink:href属性值应写为:
                getAttributeNS('http://www.w3.org/1999/xlink', 'href');
总体说来规则是比较简单的。对带有或不带有名字空间前缀的元素,以及带有名字空间前缀的属性,名字空间名称为元素或属性名字空间的URI。对不带有名字空间前缀的属性,名字空间名称为null。

2.在遍历SVG的dom时,IE下 chilldNodes只有length属性,只能通过 firstChild,nextSibling来便利DOM,也不能使用jquery的选择器在SVG dom的上下文中进行查找。

你可能感兴趣的:(jQuery,IE,XML)