Android (3.0 and later) supports SVG with ECMAScript.
The problem is that ecmacript in svg isn't executed when svg is added in the <img>
tag. I also tested it in several desktop browsers and when svg is in <img>
tag, ecmascript wasn't executed in any of them.
There are 5 ways how to add svg in the html:
- Add it as an image with the
<img>
tag
- Embed it with the
<embed>
tag
- Embed it with the
<iframe>
tag
- Embed it with the
<object>
tag
- Embed svg code directly into the html (using
<svg>
tag)
The ecmascript in the svg is executed only if the svg is embedded in <embed>
, <iframe>
or <object>
tag. When embeding svg code directly in <svg>
tag, it might be necessary to do some code changes (e.g. moving the scripts elsewhere in the html), but it should also work.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…