dispatch js實現 原生js自動觸發事件

2021-10-13 11:42:31 字數 1290 閱讀 4831

引數:eventtype 共5種型別:

events :包括所有的事件.

htmlevents:包括 'abort', 'blur', 'change', 'error', 'focus', 'load', 'reset', 'resize', 'scroll', 'select',

'submit', 'unload'. 事件

uieevents :包括 'domactivate', 'domfocusin', 'domfocusout', 'keydown', 'keypress', 'keyup'.

間接包含 mouseevents.

mouseevents:包括 'click', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup'.

mutationevents:包括 'domattrmodified', 'domnodeinserted', 'domnoderemoved',

'domcharacterdatamodified', 'domnodeinsertedintodocument',

'domnoderemovedfromdocument', 'domsubtreemodified'.

2. 在createevent後必須初始化,為大家介紹5種對應的初始化方法

htmlevents 和 通用 events:

initevent( 'type', bubbles, cancelable )

uievents :

inituievent( 'type', bubbles, cancelable, windowobject, detail )

mouseevents:

initmouseevent( 'type', bubbles, cancelable, windowobject, detail, screenx, screeny,

clientx, clienty, ctrlkey, altkey, shiftkey, metakey, button, relatedtarget )

mutationevents :

initmutationevent( 'type', bubbles, cancelable, relatednode, prevvalue, newvalue,attrname, attrchange )

3. 在初始化完成後就可以隨時觸發需要的事件了,為大家介紹targetobj.dispatchevent(event)使targetobj物件的event事件觸發需要注意的是在ie 5.5+版本上請用fireevent方法,還是瀏覽相容的考慮。

原生rabbitMq實現

原生實現rabbitmq 為什麼要使用rabbitmq訊息佇列 我們模擬這樣乙個場景,假如你在網上購物 買了東西,你支付過程5s 傳送簡訊通知5s 郵件通知等時間就更長了,你整個支的過程我們模擬這樣乙個場景,假如你在網上購物 買了東西,你支付過程5s 傳送簡訊通知5s 郵件通知等時間就更長了,你整個...

原生ajax實現

方法 描述open method,url,async 規定請求的型別 url 以及是否非同步處理請求。method 請求的型別 get 或 post。url 檔案在伺服器上的位置。async true 非同步 或 false 同步 如果不寫預設非同步 send string 將請求傳送到伺服器。st...

原生js實現Ajax

一般來說,大家可能都會習慣用jquery提供的ajax方法,但是用原生的js怎麼去實現ajax方法呢?jquery提供的ajax方法 ajax success function error function 原生js實現ajax方法 var ajax obj.send post function u...