转自: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或火狐浏览器的。

相关文章:

  • 2022-12-23
  • 2021-09-07
  • 2021-10-07
  • 2022-12-23
  • 2021-08-19
  • 2021-08-10
  • 2021-10-28
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-22
  • 2022-12-23
  • 2022-01-23
  • 2021-10-07
  • 2021-12-02
相关资源
相似解决方案