HTML 元素可擁有事件屬性,這些屬性在瀏覽器中觸發(fā)行為,比如當(dāng)用戶單擊一個(gè) HTML 元素時(shí)啟動(dòng)一段 JavaScript。下面列出的事件屬性,可以把它們插入 HTML 標(biāo)簽來定義事件行為。
HTML 5 中的新事件:onabort, onbeforeunload, oncontextmenu, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onerror, onmessage, onmousewheel, onresize, onscroll, onunload。
不再支持的 HTML 4.01 屬性:onreset
屬性如下:
| 屬性 | 值 | 描述 | 4 | 5 |
|---|---|---|---|---|
| onabort | script | 發(fā)生 abort 事件時(shí)運(yùn)行腳本。 | 5 | |
| onbeforeonload | script | 在元素加載前運(yùn)行腳本。 | 5 | |
| onblur | script | 當(dāng)元素失去焦點(diǎn)時(shí)運(yùn)行腳本。 | 4 | 5 |
| onchange | script | 當(dāng)元素改變時(shí)運(yùn)行腳本。 | 4 | 5 |
| onclick | script | 在鼠標(biāo)點(diǎn)擊時(shí)允許腳本。 | 4 | 5 |
| oncontextmenu | script | 當(dāng)菜單被觸發(fā)時(shí)運(yùn)行腳本。 | 5 | |
| ondblclick | script | 當(dāng)鼠標(biāo)雙擊時(shí)運(yùn)行腳本。 | 4 | 5 |
| ondrag | script | 只要腳本在被拖動(dòng)就允許腳本。 | 5 | |
| ondragend | script | 在拖動(dòng)操作結(jié)束時(shí)運(yùn)行腳本。 | 5 | |
| ondragenter | script | 當(dāng)元素被拖動(dòng)到一個(gè)合法的放置目標(biāo)時(shí),執(zhí)行腳本。 | 5 | |
| ondragleave | script | 當(dāng)元素離開合法的放置目標(biāo)時(shí)。 | 5 | |
| ondragover | script | 只要元素正在合法的放置目標(biāo)上拖動(dòng)時(shí),就執(zhí)行腳本。 | 5 | |
| ondragstart | script | 在拖動(dòng)操作開始時(shí)執(zhí)行腳本。 | 5 | |
| ondrop | script | 當(dāng)元素正在被拖動(dòng)時(shí)執(zhí)行腳本。 | 5 | |
| onerror | script | 當(dāng)元素加載的過程中出現(xiàn)錯(cuò)誤時(shí)執(zhí)行腳本。 | 5 | |
| onfocus | script | 當(dāng)元素獲得焦點(diǎn)時(shí)執(zhí)行腳本。 | 4 | 5 |
| onkeydown | script | 當(dāng)按鈕按下時(shí)執(zhí)行腳本。 | 4 | 5 |
| onkeypress | script | 當(dāng)按鍵被按下時(shí)執(zhí)行腳本。 | 4 | 5 |
| onkeyup | script | 當(dāng)按鈕松開時(shí)執(zhí)行腳本。 | 4 | 5 |
| onload | script | 當(dāng)文檔加載時(shí)執(zhí)行腳本。 | 4 | 5 |
| onmessage | script | 當(dāng) message 事件觸發(fā)時(shí)執(zhí)行腳本。 | 5 | |
| onmousedown | script | 當(dāng)鼠標(biāo)按鈕按下時(shí)執(zhí)行腳本。 | 4 | 5 |
| onmousemove | script | 當(dāng)鼠標(biāo)指針移動(dòng)時(shí)執(zhí)行腳本。 | 4 | 5 |
| onmouseover | script | 當(dāng)鼠標(biāo)指針移動(dòng)到一個(gè)元素上時(shí)執(zhí)行腳本。 | 4 | 5 |
| onmouseout | script | 當(dāng)鼠標(biāo)指針移出元素時(shí)執(zhí)行腳本。 | 4 | 5 |
| onmouseup | script | 當(dāng)鼠標(biāo)按鈕松開時(shí)執(zhí)行腳本。 | 4 | 5 |
| onmousewheel | script | 當(dāng)鼠標(biāo)滾輪滾動(dòng)時(shí)執(zhí)行腳本。 | 5 | |
| onreset | script | 當(dāng)表單重置時(shí)執(zhí)行腳本。不支持。 | 4 | |
| onresize | script | 當(dāng)元素調(diào)整大小時(shí)運(yùn)行腳本。 | 5 | |
| onscroll | script | 當(dāng)元素滾動(dòng)條被滾動(dòng)時(shí)執(zhí)行腳本。 | 5 | |
| onselect | script | 當(dāng)元素被選中時(shí)執(zhí)行腳本。 | 4 | 5 |
| onsubmit | script | 當(dāng)表單提交時(shí)運(yùn)行腳本。 | 4 | 5 |
| onunload | script | 當(dāng)文檔卸載時(shí)運(yùn)行腳本。 | 5 |
地 址:北京市海淀區(qū)建材城中路12號(hào)院17號(hào)樓1層119室
武漢分公司地址:湖北省武漢市洪山區(qū)南國雄楚廣場A4棟2011室
鄭州分公司地址:河南鄭州金水區(qū)東風(fēng)路科技市場對(duì)面米蘭陽光6號(hào)樓917室
郵 箱:haidanet@163.com
24小時(shí)聯(lián)系電話: 15201609116 13651084380