我的 SVG 中有许多
补充说明:如果我有类似的东西
<image xlink:href="http://example.jpg" onclick="code">
然后我需要“代码”来访问当前节点的图像 URL。
最佳答案
好吧,以下两种方法似乎都有效,尽管我不确定推荐哪一种:
onclick="window.open(this.getAttribute('xlink:href'),'_blank');"
onclick="window.open(this.getAttributeNS('http://www.w3.org/1999/xlink', 'href'), '_blank');"
关于javascript - 访问 SVG 中的图像元素 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46562456/