SVG报错error on line 39 at column 26: Namespace prefix xlink for href on script is not defined

转自:http://stackoverflow.com/questions/3561270/error-on-line-39-at-column-26-namespace-prefix-xlink-for-href-on-script-is-not

SVG写入image标签时,发现在google和火狐上无法显示,且报错: Namespace prefix xlink for href on script is not defined

后经查询,找到了解决办法:

在命名空间上添加:

xmlns:xlink=http://www.w3.org/1999/xlink

实例:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg width="100%" height="100%" version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >

<circle cx="100" cy="50" r="40" stroke="black"
stroke-width="2" fill="red"/>

<image xlink:href="happy-every-day.jpg" width="96" height="96" />

</svg>


其中红色的命名空间是使google、火狐浏览器兼容SVG的,蓝色的部分是image标签适应google或火狐浏览器的。

posted @ 2014-04-15 00:04  horizon~~~  阅读(3722)  评论(0编辑  收藏  举报