js event事件全等处理方法

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;

 

时间: 2024-09-21 10:35:28

js event事件全等处理方法的相关文章

JS冒泡事件的快速解决方法

 这篇文章主要是对JS冒泡事件的快速解决方法进行了详细的分析介绍,需要的朋友可以过来参考下,希望对大家有所帮助 何为冒泡事件 就是当设定了多个div的嵌套时:即建立了父子关系,当父div与子div共同加入了onclick事件时,当触发了子div的onclick事件后,子div进行相应的js操作.但是父div的onclick事件同样会被触发.这就造成了事件的多层并发,导致了页面混乱.这就是冒泡事件.   消除冒泡事件的方法 阻止JavaScript事件冒泡传递(cancelBubble .stop

JS创建事件的三种方法(实例代码)_基础知识

1.普通的定义方式 <input type="button" name="Button" value="确定" onclick="Sfont=prompt('请在文本框中输入红色','红色',' 提示框 '); if(Sfont=='红色'){ form1.style.fontFamily='黑体'; form1.style.color='red'; }" /> 这是最常见的一种定义方式,直接将JS事件定义在需要的

利用js ActiveXObject浏览器全屏实现方法

利用js activexobject浏览器全屏实现方法 activexobject对象是启用并返回 automation 对象的引用.使用方法: newobj = new activexobject( servername.typename[, location]) activexobject 对象语法有这些部分:其中newobj是必选项.要赋值为 activexobject 的变量名. servername是必选项.提供该对象的应用程序的名称. typename是必选项.要创建的对象的类型或类

js 绑定事件的几种方法 addEventListener()

看代码 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>添加事件的几种方法</title> <style type="text/css"> div{ width: 200px; height: 100px; background: #CCCCCC; border: 1px solid #008000; /*dis

JS冒泡事件的快速解决方法_javascript技巧

何为冒泡事件就是当设定了多个div的嵌套时:即建立了父子关系,当父div与子div共同加入了onclick事件时,当触发了子div的onclick事件后,子div进行相应的js操作.但是父div的onclick事件同样会被触发.这就造成了事件的多层并发,导致了页面混乱.这就是冒泡事件. 消除冒泡事件的方法阻止JavaScript事件冒泡传递(cancelBubble .stopPropagation) 下面的一段代码即可以很好的解释是么是冒泡效果,什么叫消除冒泡效果 复制代码 代码如下: <ht

js添加事件与选取元素方法

今天学习了几个简单的小效果,主要就是判断语句.随机数.设置元素样式和鼠标事件的学习,今天就拿来和大家分享一下. 第一个是鼠标移入和移出事件,HTML和JS代码如下:  代码如下 复制代码 <div id="main">     <label id="tishi"><input type="checkbox"  />两周内自动登陆</label>     <p id="xinxi&qu

js event事件的传递与冒泡处理_javascript技巧

复制代码 代码如下: <div> <table nclick="gotClick(event,'table',this)" id="table"> <tr nclick="gotClick(event,'tr',this)" id="tr"> <td nclick="gotClick(event,'td',this)" id="td"> &

Js event事件在IE、FF兼容性问题_javascript技巧

1.window.event IE:有window.event对象 FF:没有window.event对象.可以通过给函数的参数传递event对象. 如: 复制代码 代码如下: <input type="button" onmousemove="showDiv(event);"//event不需要加引号 function showDiv(event) { var event=window.event||event; event.clientX; event.c

js实现滑动触屏事件监听的方法

  这篇文章主要介绍了js实现滑动触屏事件监听的方法,适用于手机端触屏滑动事件的监听技巧,非常具有实用价值,需要的朋友可以参考下 本文实例讲述了js实现滑动触屏事件监听的方法.分享给大家供大家参考.具体实现方法如下: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 function span_move_fun(){