Nella mia pagina Web provo ad aggiungere uno MutationObserver
per ottenere modifiche in img src, ma ciò non funziona.L'esempio semplice dell'osservatore di mutazione in JavaScript non funziona
Ecco il codice utilizzato:
setTimeout(function() {
document.getElementById("img").src = "http://i.stack.imgur.com/aQsv7.jpg"
}, 2000);
var target = document.querySelector('#img');
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
console.log(mutation.type);
});
});
var config = {
attributes: true,
childList: false,
characterData: false
};
observer.observe(target, config);
observer.disconnect();
<img src="http://i.stack.imgur.com/k7HT5.jpg" id="img" class="pic" height="100">
Quale browser (s) hai provato? Il supporto è buono ma non è onnipresente - http://caniuse.com/#feat=mutationobserver – joews
provo in google chrome –
se chiami disconnessione non riceverai notifiche, vuoi osservare o no? – InferOn