eEhdsa

JavaScript 事件模型总结

1: 0级DOM

包括IE,FF,Safari等主流浏览器均支持,也是最经常使用的事件模型

It's easy to use, and also we are frequently using it.

2: Level 2 DOM

Every mainstream browsers supports the level 2 APIs except IE.
Evnt Spread:

step 1: capturing, spread to DOM node from "document", if any of the parent nodes have registered the special handler, then will run these handlers.
step 2: event occurs, just like level 0 DOM, the event will happen on the Node.
step 3: bubbling, it means the event will bubble-up to the "document", but not all the events will bubble-up, like: blur, focus, load, unload will never bubble-up. Also we can stop bubble-up with stopPropagation()


5: Create user event segment

  • DOM
    • Document.createEvent()
    • dispatchEvent()
    • Event.initEvent(), UIEvent.initEvent(), MouseEvent.initMouseEvent()
  • IE
    • Document.createEventObject
    • fireEvent()



遗留问题:添加eventlistener后,create event并且dispatch这个事件,然后就等于触发这个事件?
若想要做成跟onclick,onload这些完全一样该如何实现?

posted on 2009-10-09 18:10  eEhdsa  阅读(482)  评论(1编辑  收藏  举报

导航