I have
<object
data="${content}"
type="image/svg+xml"
></object>
Where content is a svg.
Currently i am trying to figure this on elm.
object
[ Attr.attribute "data" "${content}"
, Attr.type_ "image/svg+xml"
]
[]
QUESTION:
how can i find the width of the svg?
I tried in elm on "load"
but it does not fire.
Javascript or elm solution welcomed, but i prefer elm
I tried on elm
on "change" decodeImgLoad
or
on "load" decodeImgLoad
but they do not get called at all.
When i used img instead of object it worked, but i want to have the svg set up correctly on the dom and not just as image.
In elm i can not reference the svg directly, i need img or object or to convert it into elm svg.
(to convert it into elm svg is not possible, as the svg is large)
2
Answers
Okay first of all i know html and javascript not elm, so I’ll try to answer you question with javascript.
Q = Find width of svg that is in an object tag.
Ans = Use this js code
Hope this helps.
First of all this needs to run from a webserver. Running it from the filesystem does not work. SVG document must have the same origin as the HTML document. If not,
document
will benull
.Make sure that both the HTML document AND the SVG document has been loaded before starting to request the DOM. Here you have a simple example:
HTML document
SVG document (svg.svg)