Prototype Event.StopPropagation for IE >= 8

后端 未结 3 1847
遇见更好的自我
遇见更好的自我 2021-02-10 04:07

I understand the proper way to handle event.stopPropagation for IE is

if(event.stopPropagation) {
    event.stopPropagation();
} else {
    event.returnValue = f         


        
3条回答
  •  失恋的感觉
    2021-02-10 04:12

    Probably this:

    Event = Event || window.Event;
    Event.prototype.stopPropagation = Event.prototype.stopPropagation || function() {
        this.cancelBubble = true;
    }
    

    returnValue = false is an analogue for preventDefault:

    Event.prototype.preventDefault = Event.prototype.preventDefault || function () {
        this.returnValue = false;
    }
    

提交回复
热议问题