How do I run a Javascript function when the content of an <object>
has been loaded? The DOMContentLoaded
event fires before that, and things that rely on it like JQuery's $()
likewise.
Compare this to this. The first example fails because the function is executed when the external SVG hasn't been loaded. The second example polls for the elements it wants to change and only then executes the relevant code, and succeeds.
Polling works in practice, but is there a better solution for this? Ideally there would be an event fired that I can use.
Does using the onload DomEvent work?
<object onload="changeColor()" data="circles.svg" type="image/svg+xml" id="circles"></object>
see my it here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With