[英]Calling a function inside a svg file on a object tag from javascript
In my HTML page I got : 在我的HTML页面中,我得到了:
<script language="JavaScript">
function mostrar(blo) {
var str = "";
...
window.document.tbl27svg.pinta(str);
}
And in some place in the same html page I have: 在同一个html页面的某个地方,我有:
<object id="tbl27svg" data="../../imagenes/svg/tbl27.svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1100px" height="1000px" type="image/svg+xml"/>
And in the file tbl27.svg I need to call a function: 在文件tbl27.svg中,我需要调用一个函数:
parent.pinta=pinta
function inicia(event){
SVGDocument = event.target.ownerDocument;
}
function pinta(strSVG){
var nuevoNodo=parseXML(strSVG, document);
if(document.getElementById('grafico1').childNodes.length>0){
if(!document.getElementById('grafico2').childNodes.length>0)
SVGDocument.getElementById("grafico2").appendChild(nuevoNodo);
}else{
SVGDocument.getElementById("grafico1").appendChild(nuevoNodo);
}
}
So, I have tried several ways to call pinta() function on tbl27.svg file. 因此,我尝试了几种在tbl27.svg文件上调用pinta()函数的方法。 But always I got a java script error: "Object doesn't support this property or method"
但总是出现Java脚本错误:“对象不支持此属性或方法”
Be sure to place pinta()
function declaration before window.document.tbl27svg.pinta(str);
确保将
pinta()
函数声明放在window.document.tbl27svg.pinta(str);
之前window.document.tbl27svg.pinta(str);
: :
<script>
function pinta(){
...
}
function mostrar(blo) {
var str = "";
...
window.document.tbl27svg.pinta(str);
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.