Javascript svg onload功能何时发生
鉴于此:Javascript svg onload功能何时发生,javascript,svg,Javascript,Svg,鉴于此: <?xml version="1.0" standalone="yes"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100px" height="100px" version="1.1" xmlns="http://www.w3.org/2000/svg" >
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100px" height="100px" version="1.1"
xmlns="http://www.w3.org/2000/svg"
>
<text
x="20"
y="20"
onload="alert('load'); setAttribute('fill', 'fuchsia')"
onclick="setAttribute('fill', 'lightgreen')"
onmouseout="setAttribute('fill', 'black')"
>Load me</text>
</svg>
载我
我希望在svg打开时看到粉红色的文本。onclick和onmouseout按预期工作
这在firefox中不会发生。我打不开
有什么解释吗?这对我很有用
//snip...
<svg width="100px" height="100px" version="1.1" onload="alert('load'); setAttribute('fill', 'fuchsia')"
xmlns="http://www.w3.org/2000/svg"
>
//snip...
//剪断。。。
//剪断。。。
在
元素上使用onload
事件。这在所有浏览器上都可以正常工作
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<svg onload="init(evt)" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:gui="http://www.kevlindev.com/gui">
<script>var info,infoElem;
function init(e) {
if ( window.svgDocument == null )
svgDocument = e.target.ownerDocument;
infoElem = svgDocument.getElementById("info");
infoElem.setAttributeNS(null,"fill", "fuchsia");
}
function changeColor(c){
infoElem.setAttributeNS(null,"fill", c);
}</script>
<text id="info" x="20" y="20" onclick="changeColor('lightgreen')" onmouseout="changeColor('black')">Load me</text>
</svg>
var信息,infoElem;
函数init(e){
if(window.svgDocument==null)
svgDocument=e.target.ownerDocument;
infoElem=svgDocument.getElementById(“info”);
infoElem.setAttributeNS(空,“填充”,“紫红色”);
}
函数更改颜色(c){
infoElem.setAttributeNS(null,“fill”,c);
}
载我
也适用于我。奇怪的是,对不起,我不明白。我的想法是,元素E的onload是在加载E时触发的。不是这样吗?出于性能原因,Firefox只向
元素发送onload事件。