Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/457.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中的对象标记上的svg文件内调用函数_Javascript_Svg - Fatal编程技术网

在javascript中的对象标记上的svg文件内调用函数

在javascript中的对象标记上的svg文件内调用函数,javascript,svg,Javascript,Svg,在我的HTML页面中,我得到: <script language="JavaScript"> function mostrar(blo) { var str = ""; ... window.document.tbl27svg.pinta(str); } 因此,我尝试了几种方法在tbl27.svg文件上调用pinta()函数。但我总是遇到一个java脚本错误: “对象不支持此属性或方法”请确保将pinta()函数声明放在window.document.tbl2

在我的HTML页面中,我得到:

<script language="JavaScript">
  function mostrar(blo) {
   var str = "";
   ...
   window.document.tbl27svg.pinta(str);
}
因此,我尝试了几种方法在tbl27.svg文件上调用pinta()函数。但我总是遇到一个java脚本错误:
“对象不支持此属性或方法”

请确保将
pinta()
函数声明放在
window.document.tbl27svg.pinta(str)之前


函数pinta(){
...
}
功能mostrar(blo){
var str=“”;
...
window.document.tbl27svg.pinta(str);
}

pinta()
位于以下文件中:tbl27.svg和
window.document.tbl27svg.pinta(str)
位于html页面中,该页面将此文件包含在标记
中,检查
var a=document.getElementById('tbl27svg').getSVGDocument()是否正确返回一个值。@您使用的浏览器是什么?它也返回未定义的值。但我最终还是用了一些类似的东西,比如在这个页面中所做的:。这似乎奏效了。非常感谢。
<object id="tbl27svg" data="../../imagenes/svg/tbl27.svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1100px" height="1000px" type="image/svg+xml"/>
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);
    }
}
<script>
  function pinta(){
    ...
  }

  function mostrar(blo) {
    var str = "";
    ...
    window.document.tbl27svg.pinta(str);
  }
</script>