- onload事件会在所有资源加载完毕后执行,而 DOMContentLoaded 是在html加载并解析完成后才会触发。意思是
onload在 DOMContentLoaded 之后触发
。且 DOMContentLoaded 之能通过 addEventListener 方法监听
。两个事件都只能在window上监听。
window.onload = function (e) {
console.log('window onload');
};
window.addEventListener('DOMContentLoaded', function (e) {
console.log('DOMContentLoaded');
});
-
onscroll可以在window, body, document.documentElement上监听。body子元素只能在该元素上进行监听。
-
mouseout,mouseover在子元素上也会触发。mouseenter,mouseleave不会在子元素上触发。
-
键盘事件上顺序为 keydown, keypress, onbeforeinput, input, keyup。
- keypress只会在输入字符是触发,如:h,a...;按下ctrl不会触发。
- onbeforeinput firefox不会触发。
- 安卓低版本chrome内核onbeforeinput不能阻止默认行为。
- ios contenteditable 删除最后一个字符后再次按删除键时不会触发onbeforeinput。