Skip to content

Instantly share code, notes, and snippets.

@normanzb
Created December 11, 2014 13:49
Show Gist options
  • Save normanzb/137a8b9d0cf317a1be58 to your computer and use it in GitHub Desktop.
Save normanzb/137a8b9d0cf317a1be58 to your computer and use it in GitHub Desktop.
IE8 onpropertychange doesn't fire
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<input id="test" />
<script type="text/javascript">
(function(){
var count = 0;
var h;
var test = document.getElementById("test");
function onPropChange() {
if ( window.event.propertyName != 'value' ) {
return;
}
console.log('hello', count++);
if ( count > 10 ){
return;
}
test.onpropertychange = null;
test.value = '';
test.onpropertychange = onPropChange;
clearTimeout(h)
h = setTimeout(function(){
count=0;
});
};
test.onpropertychange = onPropChange;
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment