Differences in using <iframe> and <embed> for displaying SVG and scripting

前端 未结 3 1059
自闭症患者
自闭症患者 2021-01-18 01:40

I\'m trying to create Dynamic SVG graphics, it is my understanding that the only way to create dynamic SVG is to use a scripting language, so I have a few questions, basical

3条回答
  •  终归单人心
    2021-01-18 02:20

    Well, it depends on what you mean with dynamic. In most cases yes, you'll probably want scripts. There's no difference if you put your script in the HTML or the SVG file, both will be executed by the same engine.

    You can create interactive/animated svg content with the declarative animation elements (aka SMIL). You can also do simple hover effects with CSS :hover rules, or transitions with CSS3 Transitions.

    XSLT can also be used to make somewhat dynamic svg content, since it can transform your input to something else. It doesn't cover the interaction aspect though.

    You can access the svg elements from the HTML file that includes it with either of:

    theEmbeddingElement.contentDocument (preferred, but doesn't work on ) or alternatively theEmbeddingElement.getSVGDocument().

提交回复
热议问题