JSFiddle - React, Tailwind, and code Playground
HTML
<!doctype html>
<html>
<head>
<title>Object Demo</title>
</head>
<body>
<div id='containsObj'>
<object id='theObj' data='http://upload.wikimedia.org/wikipedia/commons/f/f2/Test_image_portrait_WIKIPEDIA.svg'/>
</div>
</body>
</html>
JavaScript
console.log('DOM ready');
var obj = $('#theObj')[0];
obj.addEventListener('load', function() {
obj.style.display = 'none';
obj.style.display = 'block';
console.log('SVG changed. eventListener');
console.log(obj)
});
obj.addEventListener('error', function() {
console.log('error caught, eventListener');
});
obj.onload = function() {
obj.style.display = 'none';
obj.style.display = 'block';
console.log('SVG changed. onload');
console.log(obj)
};
obj.onerror = function() {
console.log('handlind object errors supported');
};
setTimeout(function() {
obj.data = 'http://upload.wikimedia.org/wikipedia/commons/0/00/Highlight_test_image.svg';
}, 3000);
setTimeout(function() {
obj.data = 'http://uploadnotexist.wikimedia.org/wikipedia/commons/0/00/Highlight_test_image.svg';
}, 4000);