添加到SVG对象的多个链接

Ali*_*mii 4 html5 svg hyperlink xlink

我正在尝试获取一个SVG对象(欧洲地图),其中7个国家/地区被选为指向特定页面的链接.

在我的SVG文件中,我已经使用这种通用语法包装了应该是链接的每个多边形或路径:

<a xlink:href="http://www.google.com">
    <polygon class="lebanon" id="lebanon2" points="249.1,157.2 249.8,157.4 251.7,157.3 252.3,156.1 253.1,156.1 253.9,154.7 254.4,153.1 255.5,152.5 256.1,152.5 256.7,152.2 256.3,151.3 256.4,149.7 255.4,149.2 254.8,147.9 252.4,147.8 252.4,148.1 251.6,148.3 251.3,152.5 250.3,154 249.3,155.4 249.3,157"/>
</a>
Run Code Online (Sandbox Code Playgroud)

但是,在页面加载时,U会收到以下错误:

This page contains the following errors:
    error on line 32 at column 15: Namespace prefix xlink for href on a is not defined
Below is a rendering of the page up to the first error.
Run Code Online (Sandbox Code Playgroud)

我如何让它工作?

Rob*_*son 10

您的基本<svg>标记需要具有以下命名空间属性.你可能有前者而不是后者

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink">
Run Code Online (Sandbox Code Playgroud)