lundi 1 juin 2015

"DOMAttrModified" event not supported by modern browser?

Here are the codes (Jsfiddle demo) :

<a href="#">Click me!</a>

<script>
var a = document.body.children[0]

a.onclick = function() {
  alert('in onlick')
  this.setAttribute('href', 'lala')
  alert('out onclick')
  return false
}

function onpropchange() {
  alert('onpropchange')
}

if (a.addEventListener) { // FF, Opera
  a.addEventListener('DOMAttrModified', onpropchange, false)
}
if (a.attachEvent) { // IE 
  a.attachEvent('onpropertychange', onpropchange)
} 
</script>

When the <a href>Click me!</a> is clicked. The alert('onpropchange') is not executed.. (I'm using Chrome 43.0) Does anyone have any ideas about this?




Aucun commentaire:

Enregistrer un commentaire