Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我将一组 SVG 图形元素内嵌到 HTML 中时,我可以通过其 id 属性访问例如一个组,例如一个棋子,并且可以使其可点击、可拖动等。非常好,直截了当。
现在我从 HTML 中删除 SVG 代码并将其放入一个单独的文件中,我通过
<embed src=... />
进入 HTML。这在渲染中没有明显差异,但现在我无法再通过其 id 属性访问该组。和
<object data=...></object>
顺便说一句,它是一样的。
我错过了什么?
如果你的脚本在 html 文件中,你想要这样的东西......
document.getElementById("embed_or_object_id").getSVGDocument().getElementById("element_id");