简体   繁体   English

无法读取SVG文件中未定义的属性“ nodeName”

[英]Cannot read property 'nodeName' of undefined in SVG file

That error is generally caused by a script executed before the end of the loading of the page as explain here : Cannot read property childNodes of null 该错误通常是由页面加载结束之前执行的脚本引起的,如此处所述: 无法读取null的属性childNodes

But I don't think that it's my error here : 但是我不认为这是我的错误:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg onload="init(evt)" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
    <script xlink:href="jquery-1.10.2.min.js"/>
    <script xlink:href="test.js"/>
    <g id="id">

    </g>
</svg>

And the test.js file : 还有test.js文件:

function init () {
    $(document).mousedown(test)
}

function test (evt) {
    $('#id').append('test');
    $('#id').append('<rect x=10 y=10 width=50 height=50/>');
}

What is curious is that the first appending works but not the second one. 令人好奇的是,第一个追加有效,但第二个无效。 Actually the error is raise when there is an < in the string... So why ? 实际上,当字符串中有一个<时,错误就会引发。那为什么呢?

If you instantiate the element via the jQuery $('<tag_name/>') method, it works. 如果通过jQuery $('<tag_name/>')方法实例化该元素,则它可以工作。

function test (evt) {
  $('#id').append('test');
  $('#id').append($('<rect/>').attr({'x':10,'y':10,'width':50,'height':50}));
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError:无法读取未定义的属性“ nodeName” - TypeError: Cannot read property 'nodeName' of undefined 无法使用select2读取jQuery验证上未定义的nodeName属性 - Cannot read property of nodeName undefined on jQuery validation with select2 bs-tooltip TypeError:无法读取未定义的属性“nodeName” - bs-tooltip TypeError: Cannot read property 'nodeName' of undefined 错误:“无法读取未定义的属性 'nodename'” 转换 html 表时 - Error : “cannot read property 'nodename' of undefined” While converting html Table 未捕获的类型错误:无法读取 null 的属性“nodeName” - Uncaught TypeError: Cannot read property 'nodeName' of null Chrome表示无法使用Google Map API读取未定义的属性“ nodeName”,IE6很好 - Chrome says Cannot read property 'nodeName' of undefined, IE6 is fine, using Google Map API Trumboqyg 所见即所得编辑器不适用于 Jquery.Validate 插件,“Uncaught TypeError: Cannot read property 'nodeName' of undefined” - Trumboqyg WYSIWYG editor does not work with Jquery.Validate plugin, "Uncaught TypeError: Cannot read property 'nodeName' of undefined" 无法读取未定义的属性“文件” - Cannot read property 'file' of undefined jQuery 1.5.1用敲出js嘶嘶声&#39;无法读取属性节点名&#39;子&#39;&gt;&#39;选择器 - jQuery 1.5.1 Sizzle 'cannot read property nodename' child '>' selector with knockoutjs jQuery-jquery .append()产生“无法读取null的属性&#39;nodeName&#39;” - JQuery - jquery .append() produces “Cannot read property 'nodeName' of null”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM