window、document、html、body、element的事件属性比较
在分析jQuery的事件的时候有提到绑定事件的方式:
Dean Edwards的跨浏览器事件绑定使用的方式是
element["on" + type] = handleEvent;
即绑定的事件的前提条件是element.onxxx属性必须存在。
jQuery的绑定方式是使用浏览器的绑定绑定方法
if ( elem.addEventListener ) {
elem.addEventListener( type, eventHandle, false ); } else if ( elem.attachEvent ) {
elem.attachEvent( "on" + type, eventHandle );
}
为什么不用Dean Edwards使用的方式来绑定?
原因:
并非所有浏览器支持的事件都有对应的["on" + type]属性。比较典型的例子动画事件
<style>
#myDIV {
margin:25px;
width:550px;
height:100px;
background:orange;
position:relative;
font-size:20px;
}
/* Chrome, Safari, Opera */
@-webkit-keyframes mymove {
from {top: 0px;}
to {top: 200px;}
}
@keyframes mymove {
from {top: 0px;}
to {top: 200px;}
}
</style>
<p>该实例使用了 addEventListener() 方法为 DIV 元素添加"animationstart", "animationiteration" 和 "animationend" 事件。</p> <div id="myDIV" >点我开始动画</div> <script>
var x = document.getElementById("myDIV") //存在onclick属性
x.onclick = myFunction; // 使用 JavaScript 开始动画
function myFunction() {
//x.style.WebkitAnimation = "mymove 4s 2"; // Chrome, Safari 和 Opera 代码
x.style.animation = "mymove 4s 2";
} // Chrome, Safari 和 Opera
//x.addEventListener("webkitAnimationStart", myStartFunction);
//x.addEventListener("webkitAnimationIteration", myIterationFunction);
//x.addEventListener("webkitAnimationEnd", myEndFunction); x.addEventListener("animationstart", myStartFunction);
x.addEventListener("animationiteration", myIterationFunction);
x.addEventListener("animationend", myEndFunction); function myStartFunction() {
this.innerHTML = "animationstart 事件触发 - 动画已经开始";
this.style.backgroundColor = "pink";
} function myIterationFunction() {
this.innerHTML = "animationiteration 事件触发 - 动画重新播放";
this.style.backgroundColor = "lightblue";
} function myEndFunction() {
this.innerHTML = "animationend 事件触发 - 动画已经完成";
this.style.backgroundColor = "lightgray";
}
</script>
上面的例子在IE10+、webkit4.0+内核浏览器(chrome、Opera、safari)、Firefox16.0+都能正常运行。但是如果将动画的绑定事件换成
x.onanimationstart = myStartFunction;
x.onanimationiteration = myIterationFunction;
x.onanimationend = myEndFunction;
三个动画函数没有任何一个能够正常运行。
所以现在明白jQuery为什么使用原生的事件绑定方法了吧。
document.documentElement即html标签的DOM对象
document.body即body标点的DOM对象
以chrome/IE8/IE9/firefox为例,简易的比较一下window、document、html、body、element的onxxx属性
说明:表格中yes表示对象拥有该属性,否则没有
chrome45.0中所有的onxxx属性
on事件 | window | document | html | body | element |
onabort | yes | yes | yes | yes | yes |
onanimationend | yes | ||||
onanimationiteration | yes | ||||
onanimationstart | yes | ||||
onautocomplete | yes | yes | yes | yes | yes |
onautocompleteerror | yes | yes | yes | yes | yes |
onbeforeunload | yes | yes | |||
onbeforecopy | yes | yes | yes | yes | |
onbeforecut | yes | yes | yes | yes | |
onbeforepaste | yes | yes | yes | yes | |
onblur | yes | yes | yes | yes | yes |
oncancel | yes | yes | yes | yes | yes |
oncanplay | yes | yes | yes | yes | yes |
oncanplaythrough | yes | yes | yes | yes | yes |
onchange | yes | yes | yes | yes | yes |
onclick | yes | yes | yes | yes | yes |
onclose | yes | yes | yes | yes | yes |
oncontextmenu | yes | yes | yes | yes | yes |
oncuechange | yes | yes | yes | yes | yes |
ondblclick | yes | yes | yes | yes | yes |
ondevicemotion | yes | yes | yes | yes | yes |
ondeviceorientation | yes | yes | yes | yes | yes |
ondrag | yes | yes | yes | yes | yes |
ondragend | yes | yes | yes | yes | yes |
ondragenter | yes | yes | yes | yes | yes |
ondragleave | yes | yes | yes | yes | yes |
ondragover | yes | yes | yes | yes | yes |
ondragstart | yes | yes | yes | yes | yes |
ondrop | yes | yes | yes | yes | yes |
ondurationchange | yes | yes | yes | yes | yes |
onemptied | yes | yes | yes | yes | yes |
onended | yes | yes | yes | yes | yes |
onerror | yes | yes | yes | yes | yes |
onfocus | yes | yes | yes | yes | yes |
onhashchange | yes | yes | |||
oninput | yes | yes | yes | yes | yes |
oninvalid | yes | yes | yes | yes | yes |
onkeydown | yes | yes | yes | yes | yes |
onkeypress | yes | yes | yes | yes | yes |
onkeyup | yes | yes | yes | yes | yes |
onlanguagechange | yes | yes | |||
onload | yes | yes | yes | yes | yes |
onloadeddata | yes | yes | yes | yes | yes |
onloadedmetadata | yes | yes | yes | yes | yes |
onloadstart | yes | yes | yes | yes | yes |
onmessage | yes | yes | |||
onmousedown | yes | yes | yes | yes | yes |
onmouseenter | yes | yes | yes | yes | yes |
onmouseleave | yes | yes | yes | yes | yes |
onmousemove | yes | yes | yes | yes | yes |
onmouseout | yes | yes | yes | yes | yes |
onmouseover | yes | yes | yes | yes | yes |
onmouseup | yes | yes | yes | yes | yes |
onmousewheel(不推荐,用onwheel替代) | yes | yes | yes | yes | yes |
onoffline | yes | yes | |||
ononline | yes | yes | |||
onpagehide | yes | yes | |||
onpageshow | yes | yes | |||
onpaste | yes | yes | yes | yes | |
onpause | yes | yes | yes | yes | yes |
onplay | yes | yes | yes | yes | yes |
onplaying | yes | yes | yes | yes | yes |
onpopstate | yes | yes | |||
onpointerlockchange | yes | ||||
onpointerlockerror | yes | ||||
onprogress | yes | yes | yes | yes | yes |
onratechange | yes | yes | yes | yes | yes |
onreadystatechange | yes | ||||
onreset | yes | yes | yes | yes | yes |
onresize | yes | yes | yes | yes | yes |
onscroll | yes | yes | yes | yes | yes |
onsearch | yes | yes | yes | yes | yes |
onseeked | yes | yes | yes | yes | yes |
onseeking | yes | yes | yes | yes | yes |
onselect | yes | yes | yes | yes | yes |
onselectionchange | yes | ||||
onselectstart | yes | yes | yes | yes | |
onshow | yes | yes | yes | yes | yes |
onstalled | yes | yes | yes | yes | yes |
onstorage | yes | yes | |||
onsubmit | yes | yes | yes | yes | yes |
onsuspend | yes | yes | yes | yes | yes |
ontimeupdate | yes | yes | yes | yes | yes |
ontoggle | yes | yes | yes | yes | yes |
ontransitionend | yes | ||||
onunload | yes | yes | |||
onvolumechange | yes | yes | yes | yes | yes |
onwaiting | yes | yes | yes | yes | yes |
onwebkitfullscreenchange | yes | yes | yes | yes | |
onwebkitfullscreenerror | yes | yes | yes | yes | |
onwebkitanimationend | yes | ||||
onwebkitanimationiteration | yes | ||||
onwebkitanimationstart | yes | ||||
onwebkittransitionend | yes | ||||
onwheel | yes | yes | yes | yes | yes |
chrome浏览器的事件基本都都列在上面了,基本上每个事件都有.onxxx属性,连animationend这样的HTML5新事件都包含在里面了,不过需要加webkit前缀。除了一下几个比较特殊的以外:
没有onfocusin,但是支持focusin事件
没有onfocusout,但是支持focusout事件
不支持打印事件:onafterprint、onbeforeprint
Safari 3.1 到 6.0 版本才支持transitionend事件, 使用webkitTransitionEnd来绑定
查看事件的具体作用推荐:菜鸟教程HTML DOM事件
IE9中所有的onxxx属性
on事件 | window | document | html | body | element |
onabort | yes | yes | yes | yes | yes |
onactivate | yes | yes | yes | yes | |
onafterprint | yes | yes | |||
onafterupdate | yes | yes | yes | yes | |
onbeforeactivate | yes | yes | yes | yes | |
onbeforecopy | yes | yes | yes | ||
onbeforecut | yes | yes | yes | ||
onbeforedeactivate | yes | yes | yes | yes | |
onbeforeeditfocus | yes | yes | yes | yes | |
onbeforepaste | yes | yes | yes | ||
onbeforeprint | yes | yes | |||
onbeforeunload | yes | yes | |||
onbeforeupdate | yes | yes | yes | yes | |
onblur | yes | yes | yes | yes | yes |
oncanplay | yes | yes | yes | yes | yes |
oncanplaythrough | yes | yes | yes | yes | yes |
oncellchange | yes | yes | yes | yes | |
onchange | yes | yes | yes | yes | yes |
onclick | yes | yes | yes | yes | yes |
oncontextmenu | yes | yes | yes | yes | yes |
oncontrolselect | yes | yes | yes | yes | |
oncopy | yes | yes | yes | ||
oncut | yes | yes | yes | ||
ondataavailable | yes | yes | yes | yes | |
ondatasetchanged | yes | yes | yes | yes | |
ondatasetcomplete | yes | yes | yes | yes | |
ondblclick | yes | yes | yes | yes | yes |
ondeactivate | yes | yes | yes | yes | |
ondrag | yes | yes | yes | yes | yes |
ondragend | yes | yes | yes | yes | yes |
ondragenter | yes | yes | yes | yes | yes |
ondragleave | yes | yes | yes | yes | yes |
ondragover | yes | yes | yes | yes | yes |
ondragstart | yes | yes | yes | yes | yes |
ondrop | yes | yes | yes | yes | yes |
ondurationchange | yes | yes | yes | yes | yes |
onemptied | yes | yes | yes | yes | yes |
onended | yes | yes | yes | yes | yes |
onerror | yes | yes | yes | yes | yes |
onerrorupdate | yes | yes | yes | yes | |
onfilterchange | yes | yes | yes | ||
onfocus | yes | yes | yes | yes | yes |
onfocusin | yes | yes | yes | yes | yes |
onfocusout | yes | yes | yes | yes | yes |
onhashchange | yes | yes | |||
onhelp | yes | yes | yes | yes | yes |
oninput | yes | yes | yes | yes | yes |
onkeydown | yes | yes | yes | yes | yes |
onkeypress | yes | yes | yes | yes | yes |
onkeyup | yes | yes | yes | yes | yes |
onlayoutcomplete | yes | yes | yes | ||
onload | yes | yes | yes | yes | yes |
onloadeddata | yes | yes | yes | yes | yes |
onloadedmetadata | yes | yes | yes | yes | yes |
onloadstart | yes | yes | yes | yes | yes |
onlosecapture | yes | yes | yes | ||
onmessage | yes | yes | |||
onmousedown | yes | yes | yes | yes | yes |
onmouseenter | yes | yes | yes | yes | |
onmouseleave | yes | yes | yes | yes | |
onmousemove | yes | yes | yes | yes | yes |
onmouseout | yes | yes | yes | yes | yes |
onmouseover | yes | yes | yes | yes | yes |
onmouseup | yes | yes | yes | yes | yes |
onmousewheel | yes | yes | yes | yes | yes |
onmove | yes | yes | yes | ||
onmoveend | yes | yes | yes | ||
onmovestart | yes | yes | yes | ||
onmssitemodejumplistitemremoved | yes | ||||
onmsthumbnailclick | yes | ||||
onoffline | yes | yes | |||
ononline | yes | yes | |||
onpaste | yes | yes | yes | ||
onpause | yes | yes | yes | yes | yes |
onplay | yes | yes | yes | yes | yes |
onplaying | yes | yes | yes | yes | yes |
onprogress | yes | yes | yes | yes | yes |
onpropertychange | yes | yes | yes | yes | |
onratechange | yes | yes | yes | yes | yes |
onreadystatechange | yes | yes | yes | yes | yes |
onreset | yes | yes | yes | yes | yes |
onresize | yes | yes | yes | yes | yes |
onresizeend | yes | yes | yes | ||
onresizestart | yes | yes | yes | ||
onrowenter | yes | yes | yes | ||
onrowexit | yes | yes | yes | yes | |
onrowsdelete | yes | yes | yes | yes | |
onrowsinserted | yes | yes | yes | yes | |
onscroll | yes | yes | yes | yes | yes |
onseeked | yes | yes | yes | yes | yes |
onseeking | yes | yes | yes | yes | yes |
onselect | yes | yes | yes | yes | yes |
onselectionchange | yes | ||||
onselectstart | yes | yes | yes | yes | |
onstalled | yes | yes | yes | yes | yes |
onstop | yes | ||||
onstorage | yes | yes | |||
onstoragecommit | yes | ||||
onsubmit | yes | yes | yes | yes | yes |
onsuspend | yes | yes | yes | yes | yes |
ontimeupdate | yes | yes | yes | yes | yes |
onunload | yes | yes | |||
onvolumechange | yes | yes | yes | yes | yes |
onwaiting | yes | yes | yes | yes | yes |
有几个特殊的情况:
没有onpageshow,也不支持该事件,需要IE11+才支持
没有onpagehide,也不支持该事件,需要IE11+才支持
没有onsearch,IE所有版本都不支持该事件
没有onshow,IE所有版本都不支持该事件
没有ontoggle,IE所有版本都不支持该事件
没有onanimationend,也不支持该动画事件,需要IE10+才支持
没有onanimationiteration,也不支持该动画事件,需要IE10+才支持
没有onanimationstart,也不支持该动画事件,需要IE10+才支持
没有过渡ontransitionend,也不支持过渡事件,需要IE10+才支持
没有onwheel,但IE9+支持wheel绑定事件,替代onmousewheel
没有onpopstate
IE8中所有的onxxx属性
on事件 | window | document | html/script /div/a/ button/ span等普通元素 | body | form | iframe | style/link | textarea | select | input(所有type类型) |
onabort | yes | |||||||||
onactivate | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onafterprint | yes | yes | ||||||||
onafterupdate | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes |
onbeforeactivate | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onbeforecopy | yes | yes | yes | yes | yes | yes | yes | yes | ||
onbeforecut | yes | yes | yes | yes | yes | yes | yes | yes | ||
onbeforedeactivate | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onbeforeeditfocus | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onbeforepaste | yes | yes | yes | yes | yes | yes | yes | yes | ||
onbeforeprint | yes | |||||||||
onbeforeunload | yes | yes | ||||||||
onbeforeupdate | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onblur | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
oncellchange | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onchange | yes | yes | yes | |||||||
onclick | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
oncontextmenu | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
oncontrolselect | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
oncopy | yes | yes | yes | yes | yes | yes | yes | yes | ||
oncut | yes | yes | yes | yes | yes | yes | yes | yes | ||
ondataavailable | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
ondatasetchanged | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
ondatasetcomplete | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
ondblclick | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
ondeactivate | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
ondrag | yes | yes | yes | yes | yes | yes | yes | yes | ||
ondragend | yes | yes | yes | yes | yes | yes | yes | yes | ||
ondragenter | yes | yes | yes | yes | yes | yes | yes | yes | ||
ondragleave | yes | yes | yes | yes | yes | yes | yes | yes | ||
ondragover | yes | yes | yes | yes | yes | yes | yes | yes | ||
ondragstart | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
ondrop | yes | yes | yes | yes | yes | yes | yes | yes | ||
onerror | yes | yes | ||||||||
onerrorupdate | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onfilterchange | yes | yes | yes | yes | yes | yes | yes | yes | ||
onfocus | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onfocusin | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onfocusout | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onhashchange | yes | yes | ||||||||
onhelp | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes |
onkeydown | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onkeypress | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onkeyup | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onlayoutcomplete | yes | yes | yes | yes | yes | yes | yes | yes | ||
onload | yes | yes | yes | yes | yes | |||||
onlosecapture | yes | yes | yes | yes | yes | yes | yes | yes | ||
onmessage | yes | |||||||||
onmousedown | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onmouseenter | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onmouseleave | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onmousemove | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onmouseout | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onmouseover | yes | yes | yes | yes | yes | yes | yes | yes | ||
onmouseup | yes | yes | yes | yes | yes | yes | yes | yes | ||
onmousewheel | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onmove | yes | yes | yes | yes | yes | yes | yes | yes | ||
onmoveend | yes | yes | yes | yes | yes | yes | yes | yes | ||
onmovestart | yes | yes | yes | yes | yes | yes | yes | yes | ||
onmssitemodejumplistitemremoved | yes | |||||||||
onmsthumbnailclick | yes | |||||||||
onoffline | yes | |||||||||
ononline | yes | |||||||||
onpage | yes | yes | yes | yes | yes | yes | yes | yes | ||
onpaste | yes | yes | yes | yes | yes | yes | yes | yes | ||
onpropertychange | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onreadystatechange | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onreset | yes | |||||||||
onresize | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onresizeend | yes | yes | yes | yes | yes | yes | yes | yes | ||
onresizestart | yes | yes | yes | yes | yes | yes | yes | yes | ||
onrowenter | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onrowexit | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onrowsdelete | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onrowsinserted | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onscroll | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onselect | yes | yes | yes | |||||||
onselectionchange | yes | |||||||||
onselectstart | yes | yes | yes | yes | yes | yes | yes | yes | yes | |
onstop | yes | |||||||||
onstorage | yes | |||||||||
onstoragecommit | yes | |||||||||
onsubmit | yes | |||||||||
onunload | yes | yes |
除了IE9暴露的问题以外还有:
没有oninput,也不支持该事件,需要IE9+才支持
没有多媒体的onxxx属性,也不支持所有的多媒体事件(包括oncanplay/oncanplaythrough/ondurationchange/onemptied...),需要IE9+才支持
Firefox42.0中所有的onxxx属性
on事件 | window | document | html | body | element |
onabort | yes | yes | yes | yes | yes |
onafterprint | yes | yes | |||
onbeforeprint | yes | yes | |||
onbeforeunload | yes | yes | |||
onafterscriptexecute | yes | ||||
onbeforescriptexecute | yes | ||||
onblur | yes | yes | yes | yes | yes |
oncanplay | yes | yes | yes | yes | yes |
oncanplaythrough | yes | yes | yes | yes | yes |
onchange | yes | yes | yes | yes | yes |
onclick | yes | yes | yes | yes | yes |
oncontextmenu | yes | yes | yes | yes | yes |
oncopy | yes | yes | yes | yes | |
oncut | yes | yes | yes | yes | |
ondblclick | yes | yes | yes | yes | yes |
ondevicelight | yes | ||||
ondevicemotion | yes | ||||
ondeviceorientation | yes | ||||
ondeviceproximity | yes | ||||
ondrag | yes | yes | yes | yes | yes |
ondragend | yes | yes | yes | yes | yes |
ondragenter | yes | yes | yes | yes | yes |
ondragleave | yes | yes | yes | yes | yes |
ondragover | yes | yes | yes | yes | yes |
ondragstart | yes | yes | yes | yes | yes |
ondrop | yes | yes | yes | yes | yes |
ondurationchange | yes | yes | yes | yes | yes |
onemptied | yes | yes | yes | yes | yes |
onended | yes | yes | yes | yes | yes |
onerror | yes | yes | yes | yes | yes |
onfocus | yes | yes | yes | yes | yes |
onhashchange | yes | yes | |||
oninput | yes | yes | yes | yes | yes |
oninvalid | yes | yes | yes | yes | yes |
onkeydown | yes | yes | yes | yes | yes |
onkeypress | yes | yes | yes | yes | yes |
onkeyup | yes | yes | yes | yes | yes |
onlanguagechange | yes | yes | |||
onload | yes | yes | yes | yes | yes |
onloadeddata | yes | yes | yes | yes | yes |
onloadedmetadata | yes | yes | yes | yes | yes |
onloadstart | yes | yes | yes | yes | yes |
onmessage | yes | yes | |||
onmousedown | yes | yes | yes | yes | yes |
onmouseenter | yes | yes | yes | yes | yes |
onmouseleave | yes | yes | yes | yes | yes |
onmousemove | yes | yes | yes | yes | yes |
onmouseout | yes | yes | yes | yes | yes |
onmouseover | yes | yes | yes | yes | yes |
onmouseup | yes | yes | yes | yes | yes |
onmozfullscreenchange | yes | yes | yes | yes | yes |
onmozfullscreenerror | yes | yes | yes | yes | yes |
onmozpointerlockchange | yes | yes | yes | yes | yes |
onmozpointerlockerror | yes | yes | yes | yes | yes |
onoffline | yes | yes | |||
ononline | yes | yes | |||
onpagehide | yes | yes | |||
onpageshow | yes | yes | |||
onpaste | yes | yes | yes | yes | |
onpause | yes | yes | yes | yes | yes |
onplay | yes | yes | yes | yes | yes |
onplaying | yes | yes | yes | yes | yes |
onpopstate | yes | yes | |||
onprogress | yes | yes | yes | yes | yes |
onratechange | yes | yes | yes | yes | yes |
onreadystatechange | yes | ||||
onreset | yes | yes | yes | yes | yes |
onresize | yes | yes | yes | yes | yes |
onscroll | yes | yes | yes | yes | yes |
onseeked | yes | yes | yes | yes | yes |
onseeking | yes | yes | yes | yes | yes |
onselect | yes | yes | yes | yes | yes |
onshow | yes | yes | yes | yes | yes |
onstalled | yes | yes | yes | yes | yes |
onsubmit | yes | yes | yes | yes | yes |
onsuspend | yes | yes | yes | yes | yes |
ontimeupdate | yes | yes | yes | yes | yes |
onunload | yes | yes | |||
onuserproximity | yes | ||||
onvolumechange | yes | yes | yes | yes | yes |
onwaiting | yes | yes | yes | yes | yes |
onwheel | yes | yes | yes | yes | yes |
Firefox有几个比较特殊的地方:
没有onfocusin,也不支持focusin事件
没有onfocusout,也不支持focusout事件
没有onsearch,也不支持该事件
没有onanimationend,但是支持animationend事件
没有onanimationiteration,但是支持animationiteration事件
没有onanimationstart,但是支持animationstart事件
没有ontransitionend,但是支持transitionend事件
已废弃onmousewheel
没有onstorage
没有ontoggle,也不支持toggle事件
到此为止了,花费的时间不少,算是一个各个浏览器差别的笔记,比较粗略,实际上每个浏览器不同版本会有一些细微差别,不过有这这个大概的目录以后会比较容易查找不同。以后项目中如果遇到有onxxx事件绑定的问题有个参考。
如果觉得本文不错,请点击右下方【推荐】!
window、document、html、body、element的事件属性比较的更多相关文章
- JS中基本window.document对象操作以及常用事件!
一.找到元素 1.document.getELementById("id"):根据id找,最多找一个. var a=document.getELementById("id ...
- $(document).Ready()方法 VS OnLoad事件 VS $(window).load()方法
$(document).Ready()方法 VS OnLoad事件 VS $(window).load()方法接触JQuery一般最先学到的是何时启动事件.在曾经很长一段时间里,在页面载入后引发的事件 ...
- SharePoint 2013 页面中window/document.onload/ready 事件不能触发的解决方案
问题1:在SharePoint 2013页面中使用Javascript 事件window/document.onload/ready时,你会发现处理onload/ready事件的代码根本不能执行. 问 ...
- html,获取iframe的window,document,自定事件与iframe通信
获取iframe的window对象js代码如下.注意:一定要在文档加载完成之后,才能获取到 var Iframe=document.getElementById("script" ...
- js的事件属性方法一览表
event对象常用属性和方法 event 对象用来表示当前事件,事件有很多状态,例如,鼠标单击时的位置,按下键盘时的按键,发生事件的HTML元素,是否执行默认动作,是否冒泡等,这些都是作为event对 ...
- jQuery $(document).ready()和JavaScript onload事件
jQuery $(document).ready()和JavaScript onload事件 Why we need a right time? 对元素的操作和事件的绑定需要等待一个合适的时机,可以看 ...
- window.onload和window.document.readystate的探究
在编写前端页面的时候,我们时常需要对页面加载的状态进行判断,以便进行相应的操作. 比如在移动端,时常需要在页面完全加载完成之前,先显示一个loading的图标,等待页面完成加载完成后,才显示出真正要展 ...
- JS中的事件类型和事件属性的基础知识
周末无聊, 这几天又复习了下JS搞基程序设计3, 想着好记性不如浪笔头哇, 要么把这些东西写下来, 这样基础才能更加扎实么么哒, 知道的同学也可以直接过一下,当做复习, 小姨子再也不用担心我的学习啦 ...
- HTML 事件属性
HTML 事件属性一:定义二:窗口事件 (Window Events)三:表单元素事件 (Form Element Events)四:图像事件 (Image Events) 一:定义 HTML 4 的 ...
随机推荐
- Android性能优化典范第一季
2015年伊始,Google发布了关于Android性能优化典范的专题,一共16个短视频,每个3-5分钟,帮助开发者创建更快更优秀的Android App.课程专题不仅仅介绍了Android系统中有关 ...
- ENode 1.0 - Command Service设计思路
开源地址:https://github.com/tangxuehua/enode 上一篇文章,介绍了enode框架的物理部署思路.本文我们再简单分析一下Command Service的API设计: C ...
- UWP开发笔记——嵌套式页面的实现
绪论 UWP开发中,Page是最常用的Control之一,通常情况下,在开发的application中,每一个页面就是一个Page.有时候,为了开发整合度更高,UI表现更为一致的UI,开发者需要把UI ...
- 消息中间件与JMS标准
初识消息中间件 维基百科上对于消息中间件的定义是"Message-oriented middleware(MOM) is software infrastructure focused on ...
- kali linux Python开发环境初始化
kali linux Python 黑客编程1 开发环境初始化 为什么要选择Python? Python作为目前Linux系统下最流行的编程语言之一,对于安全工作者的作用可以和C++相提并论.Pyth ...
- Zookeeper--Zookeeper是什么
Google的三篇论文影响了很多很多人,也影响了很多很多系统.这三篇论文一直是分布式领域传阅的经典.根据MapReduce,于是我们有了Hadoop:根据GFS,于是我们有了HDFS:根据BigTab ...
- 【星路演】DeviceOne:跨平台APP开发平台
视频 DeviceOne是一个跨Android.IOS.Windows三个平台的一个PAAS平台,主要是提供给开发者一个节省70%的成本一个开发. 我们原来想做一个APP,我们会去找三个平台的原生人员 ...
- [开源]微信在线信息模拟测试工具(基于Senparc.Weixin.MP开发)
目前为止似乎还没有看到过Web版的普通消息测试工具(除了官方针对高级接口的),现有的一些桌面版的几个测试工具也都是使用XML直接请求,非常不友好,我们来尝试做一个“面向对象”操作的测试工具. 测试工具 ...
- Linux多线程系列-2-条件变量的使用(线程安全队列的实现)
多线程情况下,往往需要使用互斥变量来实现线程间的同步,实现资源正确共享. linux下使用如下变量和函数 //条件变量 pthread_cond_t int pthread_cond_init (pt ...
- 新特性AAtitti css3 新特性attilax总结titti css
Atitti css3 新特性attilax总结 图片发光效果2 透明渐变效果2 文字描边2 背景拉伸2 CSS3 选择器(Selector)4 @Font-face 特性7 Word-wrap &a ...