js event事件全等处理方法
国外参考文档
properties of the event constructor function:
event.capturing_phase
the value of the constant event.capturing_phase is 1.
event.at_target
the value of the constant event.at_target is 2.
event.bubbling_phase
the value of the constant event.bubbling_phase is 3.
objects that implement the event interface:
properties of objects that implement the event interface:
type
this read-only property is a string.
target
this read-only property is an object that implements the eventtarget interface.
currenttarget
this read-only property is an object that implements the eventtarget interface.
eventphase
this read-only property is a number.
bubbles
this read-only property is a boolean.
cancelable
this read-only property is a boolean.
timestamp
this read-only property is an object that implements the date interface.
namespaceuri
this read-only property is a string.
functions of objects that implement the event interface:
stoppropagation()
this function has no return value.
preventdefault()
this function has no return value.
initevent(eventtypearg, canbubblearg, cancelablearg)
this function has no return value.
the eventtypearg parameter is a string.
the canbubblearg parameter is a boolean.
the cancelablearg parameter is a boolean.
iscustom()
this function returns a boolean.
stopimmediatepropagation()
this function has no return value.
isdefaultprevented()
this function returns a boolean.
initeventns(namespaceuriarg, eventtypearg, canbubblearg, cancelablearg)
this function has no return value.
the namespaceuriarg parameter is a string.
the eventtypearg parameter is a string.
the canbubblearg parameter is a boolean.
the cancelablearg parameter is a boolean.
objects that implement the eventtarget interface:
functions of objects that implement the eventtarget interface:
addeventlistener(type, listener, usecapture)
this function has no return value.
the type parameter is a string.
the listener parameter is an object that implements the eventlistener interface.
the usecapture parameter is a boolean.
removeeventlistener(type, listener, usecapture)
this function has no return value.
the type parameter is a string.
the listener parameter is an object that implements the eventlistener interface.
the usecapture parameter is a boolean.
dispatchevent(evt)
this function returns a boolean.
the evt parameter is an object that implements the event interface.
this function can raise an object that implements the eventexception interface.
addeventlistenerns(namespaceuri, type, listener, usecapture, evtgroup)
this function has no return value.
the namespaceuri parameter is a string.
the type parameter is a string.
the listener parameter is an object that implements the eventlistener interface.
the usecapture parameter is a boolean.
the evtgroup parameter is an object that implements the object interface.
removeeventlistenerns(namespaceuri, type, listener, usecapture)
this function has no return value.
the namespaceuri parameter is a string.
the type parameter is a string.
the listener parameter is an object that implements the eventlistener interface.
the usecapture parameter is a boolean.
willtriggerns(namespaceuri, type)
this function returns a boolean.
the namespaceuri parameter is a string.
the type parameter is a string.
haseventlistenerns(namespaceuri, type)
this function returns a boolean.
the namespaceuri parameter is a string.
the type parameter is a string.
eventlistener function:
this function has no return value. the parameter is an object that implements the event interface.
properties of the eventexception constructor function:
eventexception.unspecified_event_type_err
the value of the constant eventexception.unspecified_event_type_err is 0.
eventexception.dispatch_request_err
the value of the constant eventexception.dispatch_request_err is 1.
objects that implement the eventexception interface:
properties of objects that implement the eventexception interface:
code
this property is a number.
objects that implement the documentevent interface:
functions of objects that implement the documentevent interface:
createevent(eventtype)
this function returns an object that implements the event interface.
the eventtype parameter is a string.
this function can raise an object that implements the domexception interface.
candispatch(namespaceuri, type)
this function returns a boolean.
the namespaceuri parameter is a string.
the type parameter is a string.
objects that implement the customevent interface:
objects that implement the customevent interface have all properties and functions of the event interface as well as the properties and functions defined below.
functions of objects that implement the customevent interface:
setdispatchstate(target, phase)
this function has no return value.
the target parameter is an object that implements the eventtarget interface.
the phase parameter is a number.
ispropagationstopped()
this function returns a boolean.
isimmediatepropagationstopped()
this function returns a boolean.
objects that implement the uievent interface:
objects that implement the uievent interface have all properties and functions of the event interface as well as the properties and functions defined below.
properties of objects that implement the uievent interface:
view
this read-only property is an object that implements the abstractview interface.
detail
this read-only property is a number.
functions of objects that implement the uievent interface:
inituievent(typearg, canbubblearg, cancelablearg, viewarg, detailarg)
this function has no return value.
the typearg parameter is a string.
the canbubblearg parameter is a boolean.
the cancelablearg parameter is a boolean.
the viewarg parameter is an object that implements the abstractview interface.
the detailarg parameter is a number.
inituieventns(namespaceuri, typearg, canbubblearg, cancelablearg, viewarg, detailarg)
this function has no return value.
the namespaceuri parameter is a string.
the typearg parameter is a string.
the canbubblearg parameter is a boolean.
the cancelablearg parameter is a boolean.
the viewarg parameter is an object that implements the abstractview interface.
the detailarg parameter is a number.
objects that implement the textevent interface:
objects that implement the textevent interface have all properties and functions of the uievent interface as well as the properties and functions defined below.
properties of objects that implement the textevent interface:
data
this read-only property is a string.
functions of objects that implement the textevent interface:
inittextevent(typearg, canbubblearg, cancelablearg, viewarg, dataarg)
this function has no return value.
the typearg parameter is a string.
the canbubblearg parameter is a boolean.
the cancelablearg parameter is a boolean.
the viewarg parameter is an object that implements the abstractview interface.
the dataarg parameter is a string.
inittexteventns(namespaceuri, type, canbubblearg, cancelablearg, viewarg, dataarg)
this function has no return value.
the namespaceuri parameter is a string.
the type parameter is a string.
the canbubblearg parameter is a boolean.
the cancelablearg parameter is a boolean.
the viewarg parameter is an object that implements the abstractview interface.
the dataarg parameter is a string.
objects that implement the mouseevent interface:
objects that implement the mouseevent interface have all properties and functions of the uievent interface as well as the properties and functions defined below.
properties of objects that implement the mouseevent interface:
screenx
this read-only property is a number.
screeny
this read-only property is a number.
clientx
this read-only property is a number.
clienty
this read-only property is a number.
ctrlkey
this read-only property is a boolean.
shiftkey
this read-only property is a boolean.
altkey
this read-only property is a boolean.
metakey
this read-only property is a boolean.
button
this read-only property is a number.
relatedtarget
this read-only property is an object that implements the eventtarget interface.
altgraphkey
this read-only property is a boolean.
functions of objects that implement the mouseevent interface:
initmouseevent(typearg, canbubblearg, cancelablearg, viewarg, detailarg, screenxarg, screenyarg, clientxarg, clientyarg, ctrlkeyarg, altkeyarg, shiftkeyarg, metakeyarg, buttonarg, relatedtargetarg)
this function has no return value.
the typearg parameter is a string.
the canbubblearg parameter is a boolean.
the cancelablearg parameter is a boolean.
the viewarg parameter is an object that implements the abstractview interface.
the detailarg parameter is a number.
the screenxarg parameter is a number.
the screenyarg parameter is a number.
the clientxarg parameter is a number.
the clientyarg parameter is a number.
the ctrlkeyarg parameter is a boolean.
the altkeyarg parameter is a boolean.
the shiftkeyarg parameter is a boolean.
the metakeyarg parameter is a boolean.
the buttonarg parameter is a number.
the relatedtargetarg parameter is an object that implements the eventtarget interface.
initmouseeventns(namespaceuri, typearg, canbubblearg, cancelablearg, viewarg, detailarg, screenxarg, screenyarg, clientxarg, clientyarg, ctrlkeyarg, altkeyarg, shiftkeyarg, metakeyarg, buttonarg, relatedtargetarg, altgraphkeyarg)
this function has no return value.
the namespaceuri parameter is a string.
the typearg parameter is a string.
the canbubblearg parameter is a boolean.
the cancelablearg parameter is a boolean.
the viewarg parameter is an object that implements the abstractview interface.
the detailarg parameter is a number.
the screenxarg parameter is a number.
the screenyarg parameter is a number.
the clientxarg parameter is a number.
the clientyarg parameter is a number.
the ctrlkeyarg parameter is a boolean.
the altkeyarg parameter is a boolean.
the shiftkeyarg parameter is a boolean.
the metakeyarg parameter is a boolean.
the buttonarg parameter is a number.
the relatedtargetarg parameter is an object that implements the eventtarget interface.
the altgraphkeyarg parameter is a boolean.
properties of the keyboardevent constructor function:
keyboardevent.dom_key_location_standard
the value of the constant keyboardevent.dom_key_location_standard is 0x00.
keyboardevent.dom_key_location_left
the value of the constant keyboardevent.dom_key_location_left is 0x01.
keyboardevent.dom_key_location_right
the value of the constant keyboardevent.dom_key_location_right is 0x02.
keyboardevent.dom_key_location_numpad
the value of the constant keyboardevent.dom_key_location_numpad is 0x03.
keyboardevent.dom_key_location_unknown
the value of the constant keyboardevent.dom_key_location_unknown is 0x04.
objects that implement the keyboardevent interface:
objects that implement the keyboardevent interface have all properties and functions of the uievent interface as well as the properties and functions defined below.
properties of objects that implement the keyboardevent interface:
keyidentifier
this read-only property is a string.
keylocation
this read-only property is a number.
ctrlkey
this read-only property is a boolean.
shiftkey
this read-only property is a boolean.
altkey
this read-only property is a boolean.
metakey
this read-only property is a boolean.
altgraphkey
this read-only property is a boolean.
functions of objects that implement the keyboardevent interface:
initkeyboardevent(typearg, canbubblearg, cancelablearg, viewarg, keyidentifierarg, keylocationarg, ctrlkeyarg, shiftkeyarg, altkeyarg, metakeyarg, altgraphkeyarg)
this function has no return value.
the typearg parameter is a string.
the canbubblearg parameter is a boolean.
the cancelablearg parameter is a boolean.
the viewarg parameter is an object that implements the abstractview interface.
the keyidentifierarg parameter is a string.
the keylocationarg parameter is a number.
the ctrlkeyarg parameter is a boolean.
the shiftkeyarg parameter is a boolean.
the altkeyarg parameter is a boolean.
the metakeyarg parameter is a boolean.
the altgraphkeyarg parameter is a boolean.
initkeyboardeventns(namespaceuri, type, canbubblearg, cancelablearg, viewarg, keyidentifierarg, keylocationarg, ctrlkeyarg, shiftkeyarg, altkeyarg, metakeyarg, altgraphkeyarg)
this function has no return value.
the namespaceuri parameter is a string.
the type parameter is a string.
the canbubblearg parameter is a boolean.
the cancelablearg parameter is a boolean.
the viewarg parameter is an object that implements the abstractview interface.
the keyidentifierarg parameter is a string.
the keylocationarg parameter is a number.
the ctrlkeyarg parameter is a boolean.
the shiftkeyarg parameter is a boolean.
the altkeyarg parameter is a boolean.
the metakeyarg parameter is a boolean.
the altgraphkeyarg parameter is a boolean.
properties of the mutationevent constructor function:
mutationevent.modification
the value of the constant mutationevent.modification is 1.
mutationevent.addition
the value of the constant mutationevent.addition is 2.
mutationevent.removal
the value of the constant mutationevent.removal is 3.
objects that implement the mutationevent interface:
objects that implement the mutationevent interface have all properties and functions of the event interface as well as the properties and functions defined below.
properties of objects that implement the mutationevent interface:
relatednode
this read-only property is an object that implements the node interface.
prevvalue
this read-only property is a string.
newvalue
this read-only property is a string.
attrname
this read-only property is a string.
attrchange
this read-only property is a number.
functions of objects that implement the mutationevent interface:
initmutationevent(typearg, canbubblearg, cancelablearg, relatednodearg, prevvaluearg, newvaluearg, attrnamearg, attrchangearg)
this function has no return value.
the typearg parameter is a string.
the canbubblearg parameter is a boolean.
the cancelablearg parameter is a boolean.
the relatednodearg parameter is an object that implements the node interface.
the prevvaluearg parameter is a string.
the newvaluearg parameter is a string.
the attrnamearg parameter is a string.
the attrchangearg parameter is a number.
initmutationeventns(namespaceuri, typearg, canbubblearg, cancelablearg, relatednodearg, prevvaluearg, newvaluearg, attrnamearg, attrchangearg)
this function has no return value.
the namespaceuri parameter is a string.
the typearg parameter is a string.
the canbubblearg parameter is a boolean.
the cancelablearg parameter is a boolean.
the relatednodearg parameter is an object that implements the node interface.
the prevvaluearg parameter is a string.
the newvaluearg parameter is a string.
the attrnamearg parameter is a string.
the attrchangearg parameter is a number.
objects that implement the mutationnameevent interface:
objects that implement the mutationnameevent interface have all properties and functions of the mutationevent interface as well as the properties and functions defined below.
properties of objects that implement the mutationnameevent interface:
prevnamespaceuri
this read-only property is a string.
prevnodename
this read-only property is a string.
functions of objects that implement the mutationnameevent interface:
initmutationnameevent(typearg, canbubblearg, cancelablearg, relatednodearg, prevnamespaceuri, prevnodename)
this function has no return value.
the typearg parameter is a string.
the canbubblearg parameter is a boolean.
the cancelablearg parameter is a boolean.
the relatednodearg parameter is an object that implements the node interface.
the prevnamespaceuri parameter is a string.
the prevnodename parameter is a string.
initmutationnameeventns(namespaceuri, typearg, canbubblearg, cancelablearg, relatednodearg, prevnamespaceuri, prevnodename)
this function has no return value.
the namespaceuri parameter is a string.
the typearg parameter is a string.
the canbubblearg parameter is a boolean.
the cancelablearg parameter is a boolean.
the relatednodearg parameter is an object that implements the node interface.
the prevnamespaceuri parameter is a string.
the prevnodename parameter is a string.
function a(e) {
e.abc = function() {
alert(a);
};
prevevent = e;
previeevent=window.event;
}
function b(e,event) {
e.abc(); //fn
alert(e === prevevent); //true
if(event=window.event){
alert(event===e); //false
alert(event===previeevent);//false
alert(event===prevevent);//false
}
}
var t = document.getelementbyid("p");
if (t.addeventlistener) {
t.addeventlistener('click', a, false);
t.addeventlistener('click', b, false)
} else {
t.attachevent('onclick', b);
t.attachevent('onclick', a)
}
:在fna里对event物件添加的属性,在其后执行的fnb函数里是对于event物件是否能访问到?
2:执行fna/fnb函数时的event物件是否全等 eventfna===eventfnb ?
标准的文档太长哪里是说明了这里的规则呢?懒吧...
对于jquery,同一事件,多个执行函数间的event物件是全等的。
jquery live绑定事件的实现里,对于可能会被重复执行的函数livehandler,依靠额外给event物件的livefired属性,使得在第一次之后执行的livehandler 的开始 即退出函数:
复制代码 代码如下:
if (event.livefired === this || ...) {
return;
}
///....
event.livefired = this;