zoukankan      html  css  js  c++  java
  • 201510091346_《JavaScript的事件模型——createEvent、initEvent、dispatchEvent》

    1. 存在三种事件模型:原始事件模型(所有浏览器都支持)、dom2(除ie外的浏览器都支持)事件模型、IE事件模型、Netscape事件模型。

    -----------------------------------------------------------------------------------------------------------------------------------------------

    2.详细模型

    (1)原始事件模型

        分为:语义事件onclick和输入事件onsubmit

    -------------------------------------------------------------------------

    (2)dom2事件模型

     一般分为三步:1)先由document向目标对象传播称之为:捕捉阶段;2)目标对象的事件处理程序运行,3)从目标对象向document起泡。Event.stopPropagation()可以停止                            传播,preventDefault可以阻止事件的默认动作

                              addEventListener("eventType","handler","true!false"); //true, 在捕捉的阶段调用;false,在后两个阶段调用;

                              removeEventListner("eventType","handler","true!false");

            事件合成             

          1)创建合适的事件对象:

    var e=document.createEvent("HTMLEvents");

          2)初始化事件对象域(即:属性)

    e.initEvent("click","true","true");

          3)分派事件对象:

    eventTarget.dispatchEvent();
    -------------------------------------------------------------------------                         

     (3)IE事件模型                     

                IE事件对象也有,但只是window的一个属性;目标元素的处理函数——〉document,只能捕获鼠标事件;事件处理函数的添加和删除通过:attachEvent(                                 "eventType","handler") and detachEvent("eventType","handler" );

          indow.ecent.cancelBubble=true;

                   事件注册函数:attachEvent()和反注册:detachEvent().

    -------------------------------------------------------------------------

    (4)Netscape事件模型

    -----------------------------------------------------------------------------------------------------------------------------------------------

    3. 

    前端-语言
  • 相关阅读:
    [Chapter 3 Process]Practice 3.4 Describe what happens when a context switch occurs if the new context is already loaded into one of the register sets.
    [Chapter 3 Process]Practice 3.3 Discuss three major complications that concurrent processing adds to an operating system.
    爬取:中国大学排名
    基础统计学--复习
    pandas之数据结构
    numpy之初探排序和集合运算
    numpy之统计函数和布尔数组方法
    numpy之meshgrid和where
    numpy之通用函数ufunc
    numpy之转置(transpose)和轴对换
  • 原文地址:https://www.cnblogs.com/beesky520/p/4863877.html
Copyright © 2011-2022 走看看