How to listen to a load event of an object with a SVG image?

帅比萌擦擦* 提交于 2019-12-05 08:06:01
GillesC

From this post jQuery SVG-object tag load event

It seems like jQuery simply prevents to bind a "load" event to a non-image-or-document element, so I just use the "official" addEventListener() function...

Also unsure if that's still the case but your issue was mostly that in jsfiddle you were executing the code on document "loaded" instead of document "ready". Document loaded means all the resources are loaded prior executing the code so the svg image would already be loaded.

Works fine with this updated jsfiddle http://jsfiddle.net/47jSh/2/

alert('loading');
$('#animation')[0].addEventListener('load', function() {
    alert("loaded");    
}, true);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!