Making an svg image object clickable with onclick, avoiding absolute positioning
- by user256410
I have tried to change the images on my site from to svg, changing img tags to embed and object tags(standard procedure, i think). But, implementing the onclick function, which previously was contained in the img tag is proving most difficult.
I found onclick had no effect when placed inside the object or embed tag.
So, I made a div exclusively for the svg, and placed onclick in this div tag. But, no effect unless visitor clicks on the edges/padding of the image.
I have read about overlaying a div, but am trying to avoid using absolute positioning, or specifying positions at all. Maybe there's a way to do it without specifying postions?
Or maybe theres another way to apply onclick to a svg.
Has anyone encountered this problem? Questions and suggestions are welcome.