I have tried to change the images on my site from img to svg, changing img tags to embed and object tags. Bu
When embedding same-origin SVGs using , you can access the internal contents using objectElement.contentDocument.rootElement. From there, you can easily attach event handlers (e.g. via onclick, addEventListener(), etc.)
For example:
var object = /* get DOM node for
Note that this is not possible for cross-origin elements unless you also control the origin server and can set CORS headers there. For cross-origin cases without CORS headers, access to contentDocument is blocked.