简体   繁体   English

如何在SVG中包含jQuery SVG源代码?

[英]How to include jQuery SVG source in SVG?

Is it possible to include jQuery SVG source code in a standalone SVG document? 是否可以在独立的SVG文档中包含jQuery SVG源代码? I mean like: 我的意思是:

<script type="application/javascript">
    <![CDATA[
        // jQuery SVG code
    ]]>
</script>

I need the SVG document to be independent of other files. 我需要SVG文档独立于其他文件。 (copy it elsewhere and it will work without any other files, internet connection,...) (将其复制到其他位置,它将在没有任何其他文件,互联网连接的情况下正常工作...)
Trying so, I get: 这样做,我得到:

error on line 383 at column 16623: StartTag: invalid element name 在第16623行的383行上出现错误:StartTag:无效的元素名称

Which is: 这是:

b='<'+a.nodeName;

How to make it seem as a string, not a start tag? 如何使它看起来像字符串,而不是开始标记? I'm unable to make it work by commenting out CDATA parts or the script as whole (I have tried //, /* */ and <!-- --> ). 我无法通过注释掉CDATA部分或整个脚本来使其工作(我尝试过//,/ ** /和<!-- --> )。 I guess I'm missing something simple here... 我想我在这里错过了一些简单的事情...

Here is an example SVG document with a simple JS script with jQuery 1.6.4 and jQuery SVG 1.4.4 source codes: http://dl.dropbox.com/u/5552845/test.svg Note: moving jQuery SVG source code out will lead to perfectly working SVG document 这是一个示例SVG文档,其中包含带有jQuery 1.6.4和jQuery SVG 1.4.4源代码的简单JS脚本: http : //dl.dropbox.com/u/5552845/test.svg注意:将jQuery SVG源代码移出将导致完美运行的SVG文档

jQuery SVG includes the string ']]>', which ends the cdata block. jQuery SVG包含字符串']]>',该字符串结束了cdata块。

If you change ']]>' to ']'+']>' the file becomes valid. 如果将']]>'更改为']'+']>',该文件将变为有效。

see http://dl.dropbox.com/u/3885046/test.svg 参见http://dl.dropbox.com/u/3885046/test.svg

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM