Closed SamuelJoly closed 3 years ago
The easiest solution would be (for static links) to use something like this:
<?xml version="1.0"?>
<svg viewBox="0 0 120 120" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<circle id="circle" cx="60" cy="60" r="50" onclick="window.location.href = 'https://google.com';"/>
</svg>
to do more sophisticated on click events you can try the svg.js event handling: https://svgjs.com/docs/3.0/events/
Hey @SamuelJoly the SVG.js library allows attachement of arbitrary events to elements with the on('event', handler)
method on each element in your svgmap.
svgmap.YourCycle.click(function() { open("http://www.cnn.com/", "CNN_WindowName"); });
Is there a way to program an "onclick" link. Like for example, if I the user would click on my SVG circle, it would send him to another page. Can we do that?
I tried this without sucess: https://medium.com/@gianpaul.r/adding-clickable-links-to-an-svg-image-file-f254e0f6b71a