溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

HTML5事件有哪些

發(fā)布時(shí)間:2021-09-15 14:12:51 來源:億速云 閱讀:135 作者:柒染 欄目:web開發(fā)

本篇文章給大家分享的是有關(guān)HTML5事件有哪些,小編覺得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

下面的表格列出了可插入 HTML 5 元素中以定義事件行為的標(biāo)準(zhǔn)事件屬性。

  • Window 事件屬性 - Window Event Attributes

  • 表單事件 - Form Events

  • 鍵盤事件 - Keybord Events

  • 鼠標(biāo)事件 - Mouse Events

  • 媒介事件 - Media Events


Window 事件屬性

window 對象觸發(fā)的事件。適用于 <body> 標(biāo)簽:

屬性描述
onafterprintscript在打印文檔之后運(yùn)行腳本
onbeforeprintscript在文檔打印之前運(yùn)行腳本
onbeforeonloadscript在文檔加載之前運(yùn)行腳本
onblurscript當(dāng)窗口失去焦點(diǎn)時(shí)運(yùn)行腳本
onerrorscript當(dāng)錯(cuò)誤發(fā)生時(shí)運(yùn)行腳本
onfocusscript當(dāng)窗口獲得焦點(diǎn)時(shí)運(yùn)行腳本
onhaschangescript當(dāng)文檔改變時(shí)運(yùn)行腳本
onloadscript當(dāng)文檔加載時(shí)運(yùn)行腳本
onmessagescript當(dāng)觸發(fā)消息時(shí)運(yùn)行腳本
onofflinescript當(dāng)文檔離線時(shí)運(yùn)行腳本
ononlinescript當(dāng)文檔上線時(shí)運(yùn)行腳本
onpagehidescript當(dāng)窗口隱藏時(shí)運(yùn)行腳本
onpageshowscript當(dāng)窗口可見時(shí)運(yùn)行腳本
onpopstatescript當(dāng)窗口歷史記錄改變時(shí)運(yùn)行腳本
onredoscript當(dāng)文檔執(zhí)行再執(zhí)行操作(redo)時(shí)運(yùn)行腳本
onresizescript當(dāng)調(diào)整窗口大小時(shí)運(yùn)行腳本
onstoragescript當(dāng)文檔加載加載時(shí)運(yùn)行腳本
onundoscript當(dāng) Web Storage 區(qū)域更新時(shí)(存儲空間中的數(shù)據(jù)發(fā)生變化時(shí))
onunloadscript當(dāng)用戶離開文檔時(shí)運(yùn)行腳本

表單事件

由 HTML 表單內(nèi)部的動作觸發(fā)的事件。適用于所有 HTML 5 元素,不過最常用于表單元素中:

屬性描述
onblurscript當(dāng)元素失去焦點(diǎn)時(shí)運(yùn)行腳本
onchangescript當(dāng)元素改變時(shí)運(yùn)行腳本
oncontextmenuscript當(dāng)觸發(fā)上下文菜單時(shí)運(yùn)行腳本
onfocusscript當(dāng)元素獲得焦點(diǎn)時(shí)運(yùn)行腳本
onformchangescript當(dāng)表單改變時(shí)運(yùn)行腳本
onforminputscript當(dāng)表單獲得用戶輸入時(shí)運(yùn)行腳本
oninputscript當(dāng)元素獲得用戶輸入時(shí)運(yùn)行腳本
oninvalidscript當(dāng)元素?zé)o效時(shí)運(yùn)行腳本
onresetscript當(dāng)表單重置時(shí)運(yùn)行腳本。HTML 5 不支持。
onselectscript當(dāng)選取元素時(shí)運(yùn)行腳本
onsubmitscript當(dāng)提交表單時(shí)運(yùn)行腳本

鍵盤事件

由鍵盤觸發(fā)的事件。適用于所有 HTML 5 元素:

屬性描述
onkeydownscript當(dāng)按下按鍵時(shí)運(yùn)行腳本
onkeypressscript當(dāng)按下并松開按鍵時(shí)運(yùn)行腳本
onkeyupscript當(dāng)松開按鍵時(shí)運(yùn)行腳本

鼠標(biāo)事件

由鼠標(biāo)或相似的用戶動作觸發(fā)的事件。適用于所有 HTML 5 元素:

屬性描述
onclickscript當(dāng)單擊鼠標(biāo)時(shí)運(yùn)行腳本
ondblclickscript當(dāng)雙擊鼠標(biāo)時(shí)運(yùn)行腳本
ondragscript當(dāng)拖動元素時(shí)運(yùn)行腳本
ondragendscript當(dāng)拖動操作結(jié)束時(shí)運(yùn)行腳本
ondragenterscript當(dāng)元素被拖動至有效的拖放目標(biāo)時(shí)運(yùn)行腳本
ondragleavescript當(dāng)元素離開有效拖放目標(biāo)時(shí)運(yùn)行腳本
ondragoverscript當(dāng)元素被拖動至有效拖放目標(biāo)上方時(shí)運(yùn)行腳本
ondragstartscript當(dāng)拖動操作開始時(shí)運(yùn)行腳本
ondropscript當(dāng)被拖動元素正在被拖放時(shí)運(yùn)行腳本
onmousedownscript當(dāng)按下鼠標(biāo)按鈕時(shí)運(yùn)行腳本
onmousemovescript當(dāng)鼠標(biāo)指針移動時(shí)運(yùn)行腳本
onmouseoutscript當(dāng)鼠標(biāo)指針移出元素時(shí)運(yùn)行腳本
onmouseoverscript當(dāng)鼠標(biāo)指針移至元素之上時(shí)運(yùn)行腳本
onmouseupscript當(dāng)松開鼠標(biāo)按鈕時(shí)運(yùn)行腳本
onmousewheelscript當(dāng)轉(zhuǎn)動鼠標(biāo)滾輪時(shí)運(yùn)行腳本
onscrollscript當(dāng)滾動元素滾動元素的滾動條時(shí)運(yùn)行腳本

媒介事件

由視頻、圖像以及音頻等媒介觸發(fā)的事件。適用于所有 HTML 5 元素,不過在媒介元素(諸如 audio、embed、img、object 以及 video)中最常用:

屬性描述
onabortscript當(dāng)發(fā)生中指事件時(shí)運(yùn)行腳本
oncanplayscript當(dāng)媒介能夠開始播放但可能因緩沖而需要停止時(shí)運(yùn)行腳本
oncanplaythroughscript當(dāng)媒介能夠無需因緩沖而停止即可播放至結(jié)尾時(shí)運(yùn)行腳本
ondurationchangescript當(dāng)媒介長度改變時(shí)運(yùn)行腳本
onemptiedscript當(dāng)媒介資源元素突然為空時(shí)(網(wǎng)絡(luò)錯(cuò)誤、加載錯(cuò)誤等)運(yùn)行腳本
onendedscript當(dāng)媒介已抵達(dá)結(jié)尾時(shí)運(yùn)行腳本
onerrorscript當(dāng)在元素加載期間發(fā)生錯(cuò)誤時(shí)運(yùn)行腳本
onloadeddatascript當(dāng)加載媒介數(shù)據(jù)時(shí)運(yùn)行腳本
onloadedmetadatascript當(dāng)媒介元素的持續(xù)時(shí)間以及其他媒介數(shù)據(jù)已加載時(shí)運(yùn)行腳本
onloadstartscript當(dāng)瀏覽器開始加載媒介數(shù)據(jù)時(shí)運(yùn)行腳本
onpausescript當(dāng)媒介數(shù)據(jù)暫停時(shí)運(yùn)行腳本
onplayscript當(dāng)媒介數(shù)據(jù)將要開始播放時(shí)運(yùn)行腳本
onplayingscript當(dāng)媒介數(shù)據(jù)已開始播放時(shí)運(yùn)行腳本
onprogressscript當(dāng)瀏覽器正在取媒介數(shù)據(jù)時(shí)運(yùn)行腳本
onratechangescript當(dāng)媒介數(shù)據(jù)的播放速率改變時(shí)運(yùn)行腳本
onreadystatechangescript當(dāng)就緒狀態(tài)(ready-state)改變時(shí)運(yùn)行腳本
onseekedscript當(dāng)媒介元素的定位屬性[1]不再為真且定位已結(jié)束時(shí)運(yùn)行腳本
onseekingscript當(dāng)媒介元素的定位屬性為真且定位已開始時(shí)運(yùn)行腳本
onstalledscript當(dāng)取回媒介數(shù)據(jù)過程中(延遲)存在錯(cuò)誤時(shí)運(yùn)行腳本
onsuspendscript當(dāng)瀏覽器已在取媒介數(shù)據(jù)但在取回整個(gè)媒介文件之前停止時(shí)運(yùn)行腳本
ontimeupdatescript當(dāng)媒介改變其播放位置時(shí)運(yùn)行腳本
onvolumechangescript當(dāng)媒介改變音量亦或當(dāng)音量被設(shè)置為靜音時(shí)運(yùn)行腳本
onwaitingscript當(dāng)媒介已停止播放但打算繼續(xù)播放時(shí)運(yùn)行腳本

[1]:定位屬性的英文譯文是:seeking attribute。

以上就是HTML5事件有哪些,小編相信有部分知識點(diǎn)可能是我們?nèi)粘9ぷ鲿姷交蛴玫降?。希望你能通過這篇文章學(xué)到更多知識。更多詳情敬請關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI