I need to check if an OBJECT-tag is loaded and in some edge cases the OBJECT is loaded before the JavaScript is run and then my function will never fire.
<object type="image/svg+xml" data="svg/europas-ledande-online-butik.svg">Europas ledande online butik</object>
obj.addEventListener('load', function svgLoad() {..
How can I check if my OBJECT is loaded already?
I COULD do: object onload="store some global variable"
and later check for it ,but that's clunky and ugly.
I CAN'T check the width or the height, because I don't know the values (it's added thru a CMS)
Ideas?
The example above just so happens to be an SVG, but it can be any element with an additional external data request - object, image, embed what ever.
As stated above: ONLOAD
is not something I wish to do (separation of concerns - inline event handlers are bad for you) and addEventListener
doesn't work on elements that are already loaded.
Of course I wish to trigger my svgLoad-function ASAP - as soon as the objects are ready to be shown.