chessweb
chessweb

Reputation: 4645

SVG in HTML: Inline vs. embed

When I embed a set of SVG graphics elements inline into HTML I have access to e.g. a group, say a chesspiece, via its id-attribute and can make it clickable, draggable and so on. Very nice and straight forward.

Now I remove the SVG code from the HTML and put it into a separate file which I include via

<embed src=... /> 

into the HTML. This works with no apparent difference in the rendering, but now I don't have access to the group via its id-attribute any more. With

<object data=...></object> 

it is the same, by the way.

What am I missing?

Upvotes: 1

Views: 799

Answers (1)

Robert Longson
Robert Longson

Reputation: 124109

If you have your script in the html file, you want something like this...

document.getElementById("embed_or_object_id").getSVGDocument().getElementById("element_id");

Upvotes: 1

Related Questions