style.backgroundImage will fire onpropertychange twice

We all know IE is weird:

<input id="mytestinput" οnclick="this.style.backgroundImage='url(http://blog.csdn.net/images/authorship.gif)';" type="button" value="change background image" />
<script>
document.getElementById('mytestinput').attachEvent(
    'onpropertychange', function () { alert(event.propertyName); });
</script>

<script> document.getElementById('mytestinput').attachEvent('onpropertychange', function () { alert(event.propertyName); }); </script>

click the button will alert twice.

If u set backgroundImage to 'none', it will also alert twice, however, set to ''(empty string), will only once...

發佈了125 篇原創文章 · 獲贊 0 · 訪問量 36萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章