Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/471.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Raphael.js属性和VML_Javascript_Attributes_Svg_Raphael_Vml - Fatal编程技术网

Javascript Raphael.js属性和VML

Javascript Raphael.js属性和VML,javascript,attributes,svg,raphael,vml,Javascript,Attributes,Svg,Raphael,Vml,对于Raphael,我想创建一个具有Id属性的矩形,如下例所示 <rect id="aRect" x="10" y="10" width="50" height="50" r="2" rx="2" ry="2"/> 并使用如下代码设置Id var elem = _paper.rect(10, 10, 50, 50, 2); elem[0].setAttributeNS(null, 'id', 'aRect'); elem.node.id = 'aRect'; 或者使用这样的代

对于Raphael,我想创建一个具有Id属性的矩形,如下例所示

<rect id="aRect" x="10" y="10" width="50" height="50" r="2" rx="2" ry="2"/>
并使用如下代码设置Id

var elem = _paper.rect(10, 10, 50, 50, 2);
elem[0].setAttributeNS(null, 'id', 'aRect');
elem.node.id = 'aRect';
或者使用这样的代码

var elem = _paper.rect(10, 10, 50, 50, 2);
elem[0].setAttributeNS(null, 'id', 'aRect');
elem.node.id = 'aRect';
现在raphael回到了旧IE右侧的vml,我如何添加一个id属性来满足vml的情况,或者该代码是否也适用于该情况?

在阅读MS页面后,我实现了这个设置id的解决方案

function setId(el, id){
    if(el === null || typeof el !== 'object') return;
    if(Raphael.type === 'SVG') {
        el[0].setAttributeNS(null, 'id', id);
    }
    else if(Raphael.type === 'VML') {
        el[0].id = id;
    }
}