Making an svg image object clickable with onclick, avoiding absolute positioning

Posted by user256410 on Stack Overflow See other posts from Stack Overflow or by user256410
Published on 2010-02-19T12:05:47Z Indexed on 2010/04/12 10:43 UTC
Read the original article Hit count: 634

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about html

Related posts about svg