Rumah  >  Artikel  >  hujung hadapan web  >  Acara HTML

Acara HTML

WBOY
WBOYasal
2024-09-04 16:14:20842semak imbas

Dalam halaman web atau tapak web yang dibuat menggunakan skrip HTML (HyperText Markup Language), setiap tindakan yang dilakukan oleh pengguna dan alat web itu sendiri dipanggil Acara HTML. Perihalan mengandungi enam jenis atribut untuk setiap Peristiwa: atribut acara tetingkap, atribut acara bentuk, atribut acara papan kekunci, atribut acara tetikus, atribut acara media dan atribut acara papan keratan. Setiap atribut acara ini akan mempunyai atribut khusus khusus yang digunakan untuk mengambil butiran Acara HTML.

Jenis Acara HTML yang Berbeza

Terdapat banyak atribut acara yang tersedia dalam HTML5, yang dikelaskan terutamanya kepada 6 jenis yang berbeza. Atribut ini berfungsi menggunakan bahasa JavaScript.

Acara HTML

  •  Atribut Acara Windows: Ini disediakan untuk tindakan objek windows. Ia berfungsi dalam tag badan  .
  •  Borang Atribut Acara: Jika pengguna melakukan beberapa tindakan dalam borang seperti data input, batalkan, serahkan, maka atribut acara ini berfungsi.
  •  Atribut Acara Papan Kekunci: Atribut acara papan kekunci ini digunakan untuk tindakan papan kekunci dan interaksi pengguna.
  •  Atribut Acara Tetikus: Atribut acara tetikus yang digunakan untuk tindakan tetikus iaitu bergerak, klik, roda, dsb.
  •  Atribut Acara Papan Keratan: Atribut acara ini digunakan untuk tindakan papan keratan: contoh, potong, salin, perosak.
  •  Atribut Acara Media: Atribut acara ini berfungsi pada fail media seperti video dll.

Penerangan Atribut Acara

Berikut ialah beberapa penjelasan tentang atribut acara yang diberikan di bawah secara terperinci:

1. Atribut Acara Windows

Attribute

Description

onafterprint This script act, though, after the document printed.
onbeforeprint This script act, though, before a document printed.
onbeforeunload Whereas before the unloaded document, this Script works.
onerror  In the document occurs the Error then this event executed.
onhashchange  The anchor part of URL change in the document that time event executed.
onload When the first Web page is loaded completely, then this event executed.
onmessage In the document, the message that occurred at that time event executed.
onoffline If the network connection is unavailable and the browser says offline, then the event executed.
ononline When the network available in the browser, then the event executed.
onpagehide This script act; if the user not working on a current webpage, a then-current page can be hidden.
onpageshow This script act at that time the current webpage is load.
onpopstate This script automatically works on the browser for a history state change.
onresize This script act when the browser of the window changes the size.
onstorage When users web storage updated, then the event executed.
onunload The user’s current web page is not loaded or the window is closed, then the event is executed.
Atribut

Penerangan

onafterprint Namun, skrip ini bertindak selepas dokumen dicetak.
pada sebelum dicetak Namun, skrip ini bertindak sebelum dokumen dicetak.
onbeforeunload Manakala sebelum dokumen yang dipunggah, Skrip ini berfungsi.
satu kesilapan  Dalam dokumen berlaku Ralat kemudian peristiwa ini dilaksanakan.
onhashchange  Bahagian utama perubahan URL dalam dokumen yang peristiwa masa itu dilaksanakan.
dimuat Apabila halaman Web pertama dimuatkan sepenuhnya, maka acara ini dilaksanakan.
pada mesej Dalam dokumen, mesej yang berlaku pada peristiwa masa itu dilaksanakan.
dalam talian Jika sambungan rangkaian tidak tersedia dan penyemak imbas berkata di luar talian, maka acara itu dilaksanakan.
dalam talian Apabila rangkaian tersedia dalam penyemak imbas, maka acara itu dilaksanakan.
onpagehide Tindakan skrip ini; jika pengguna tidak bekerja pada halaman web semasa, halaman semasa boleh disembunyikan.
onpageshow Skrip ini bertindak pada masa itu halaman web semasa dimuatkan.
onpopstate Skrip ini berfungsi secara automatik pada penyemak imbas untuk perubahan keadaan sejarah.
onresize Skrip ini bertindak apabila penyemak imbas tetingkap menukar saiz.
penyimpanan Apabila storan web pengguna dikemas kini, maka acara itu dilaksanakan.
memuat turun Halaman web semasa pengguna tidak dimuatkan atau tetingkap ditutup, kemudian acara itu dilaksanakan.

2. Bentuk Atribut Acara

Attribute Description
onblur Some form validation object loos the focus, then event fired.
onchange The value change in the form, then event fired.
onfocus In the form , ,
oninput The user gives input of value in the form then this event fired.
oninvalid The event works on when the element does not satisfy its predefined constraints.
onreset User reset the form information, then event fired.
onsearch Users search the required field, then event fired.
onselect The user selects the text or text area in form, then event fired.
onsubmit The user submits the form at the end then the event fired.

3. Atribut Acara Papan Kekunci

Attribute    Description
onkeydown Using a keyboard, the user press the key down at that point event works
onkeypress Using the keyboard, users press the key and display characters at that point event works.
onkeyup After the press, the key user releases the key then the event works.

4. Atribut Acara Tetikus

   Attribute Description
onclick The user clicks the mouse on the button then an event occurred.
ondblclick Users double click the mouse then the event occurred.
onmousedown The user presses the mouse button on the element then the event occurred.
onmousemove The user moves the mouse pointer over the element then the event occurred.
onmouseout The user moves the mouse outside of the element then the event occurred.
onmouseover  The user moves the mouse over the element then the event occurred.
onmouseup The user released the mouse button then the event occurred.
onmousewheel Using the mouse wheel user rolls the up and down on element then the event occurred.
onwheel Using a mouse wheel user roll them up and down then the event occurred.

5. Atribut Acara Papan Klip

 Attribute Description
oncopy Using mouse users to copy the content, then the event occurred.
oncut Using a mouse, users cut the content then the event occurred.
onpaste Using a mouse user, paste the content, then an event occurred.

6. Atribut Acara Media

Attribute Description
onabort When media files aborted for download and play again, then an event occurs.
oncanplay When any media file ready for play, then this trigger is fired.
oncanplaythrough Media file ready to play without buffering and loading.
oncuechange Element changes the cue of then event fired.
ondurationchange The Media file changes the length of time then the trigger is fired.
onemptied If the Media file unavailable and come fatal error, then the trigger is fired.
onended The Media file comes on endpoint then the trigger is fired.
onerror When an error occurred to get the media file, the trigger is fired
onloadeddata The Media file loads the data then the trigger is fired.
onloadedmetadata The Media file loads the metadata then the trigger is fired.
onloadstart The Media file starts to load then the trigger is fired.
onpause The Media file paused to play again then the trigger is fired.
onplay Media file ready to play, then trigger is fired.
onplaying The Media file starts to play when the trigger is fired.
onprogress This script act when the browser is working on connecting with the media data.
onratechange If the videos playback speed is changed, then the trigger is fired.
onseeked Users completed moving; otherwise, skip the new position of video. this attribute set as false.
onseeking The user wants to move; otherwise, skip the new position of the video. this attribute set as true.
onstalled When the browser suddenly stops to the connection of data, then the event works.
onsuspend When the web Browser on purpose does not get media data, then events work.
ontimeupdate When a user changes the video play position like forward and backward.
onvolumechange To change media volume low to high.
onwaiting If the data load the information, current video stop with buffering then event works.

Kesimpulan

Acara Html ialah cara mudah untuk mengambil tindakan dan antara muka antara penyemak imbas web dan pengguna. Pengguna boleh mendapatkan reaksi setiap tindakan tanpa susah payah. Contohnya, potong dan salin untuk papan keratan, gerakkan dan klik untuk tetikus, butang untuk borang. Acara menjadikan aplikasi web dalam masa nyata dan membuat sistem kerja pintar.

Atas ialah kandungan terperinci Acara HTML. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:Perintah HTMLArtikel seterusnya:Perintah HTML