Emulate W3C event capturing model in IE

前端 未结 6 1357
野趣味
野趣味 2021-02-07 11:54

Is it possible to emulate event capturing in Internet Explorer?

An example:

one
two
three3



        
6条回答
  •  野的像风
    2021-02-07 12:34

    The best way if you use only bubbling for clicks:

    if (document.addEventListener) document.addEventListener("click", function(e){e.preventDefault();},false);
    else if (document.attachEvent) document.attachEvent("onclick", function(){window.event.returnValue = false;});
    

提交回复
热议问题