1 //event object Library;2 varEventutil={3Addevent:function(OBJ,TYPE,FN) {4 if(obj.addeventlistener) {5Obj.addeventlistener (TYPE,FN,false);6}Else if(obj.attachevent) {7Obj.attachevent (' on ' +TYPE,FN);8 }9 },TenRemoveevent:function(OBJ,TYPE,FN) { One if(obj.removeeventlistener) { AObj.removeevent (TYPE,FN,false); -}Else if(obj.detachevent) { -Obj.detachevent (' on ' +TYPE,FN); the } - }, -GetEvent:function(e) {//Get Event Object - returne.target| |event.srcelement; + }, -Preventdefault:function(e) {//block default behavior; + if(e.preventdefault) { A E.preventdefault (); at}Else{ -E.returnvalue=false; - } - }, -Stoppropagation:function(e) {//stop bubbling; - if(e.stoppropagation) { in e.stoppropagation (); -}Else{ toe.cancelbubble=true; + } - }, theCLIENTXY:function(e) {//gets the mouse position within the visible range; * vart=document.documentelement.scrolltop| |Document.body.scrollTop; $ varl=document.documentelement.scrollleft| |Document.body.scrollLeft;Panax Notoginseng return{X:l+clientx, y:t+E.clienty}; - }, theGetrelatedtarget:function(e) { + if(e.relatedtarget) { A returnE.relatedtarget; the}Else if(event.toelement) { + returne.toelement; -}Else if(e.toelement) { $ returne.fromelement; $}Else{ - return NULL; - } the }, -Getbutton:function(e) {Wuyi if(Document.implementation.hasFeature ("Mouseevents", "2.0")){ the returnE.button; -}Else{ Wu Switch(E.button) { - Case0: About Case1: $ Case3: - Case5: - Case7: - return0; A Case2: + Case6: the return2; - Case4: $ return1; the } the } the }, theGetcharcode:function(e) { - if(typeofevent.charcode== ' number '){ in returnE.charcode; the}Else{ the returnE.keycode; About } the }, theGetwheeldelta:function(e) { the if(E.wheeldelta) { + return(Client.engine.opera && client.engine.opera<9.5?-Event.wheelDelta:event.wheelDelta); -}Else{ the return-event.detail *40;Bayi } the } the};
Event Object Library