[英]Redirect to other HTML via onclick function on a SVG Element
I am trying to redirect to another HTML Page when i click on my svg element.当我点击我的 svg 元素时,我试图重定向到另一个 HTML 页面。 Here is how i tried it.
这是我尝试的方法。
draw.rect(300, 250).move(1100, 200).attr ({
fill: 'grey',
stroke: '#000',
'stroke-width': 3
})
.click(function() {
href="./index.html"
})
Would apreciate some help会很感激一些帮助
You can wrap the rect in a <a>
element like so:您可以将矩形包裹在
<a>
元素中,如下所示:
svg{border:solid}
<svg width="250" viewBox="-10 -10 320 220"> <a xlink:href="https://stackoverflow.com/"> <rect width="300" height="200" fill="grey" stroke="#000" stroke-width="3" /> </a> </svg>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.