event object properties and methods, and compatibility wording

event Usage
major browsers
1.event.target click so and so is the target, the event source
2.event.current event binding points to who is who in Who
3.event.type type of event (onclick, onmousemove etc.)
4.event.preventDefault ( ) to prevent the default behavior
5.event.stopPropagation () prevent the event from bubbling or capture
6.event.clientY refers to the top of the browser to the bottom position of the mouse
7.event.pageY refers to the top of the browser to the bottom of the mouse position, but it calculates the distance of the scroll bar
at the top of the screen to the mouse position 8.event.screenY

IE8 and below event usage (attachEvent ( "onclick", function (event) {}))
1.event.type event type
2.event.returnValue = false to prevent the default behavior
3.event.cancelBubble = true to prevent the event from bubbling or capture
click 4.event.srcElement so and so is the target, the event source

Compatibility wording

var eventUntil={
     getTarget:function(event){
        return event.srcElement || event.target
     },
     preventDefault:function(event){
        if(event.preventDefault){
            event.preventDefault()
        }else{
            event.returnValue=false
        }
     },
     stopPropagation:function(event){
        if(event.stopPropagation){
            event.stopPropagation()
        }else{
            event.cancelBubble  = true
        }
     }
}
Published 25 original articles · won praise 0 · Views 634

Guess you like

Origin blog.csdn.net/JamesHKK/article/details/104779845