Heim  >  Artikel  >  Web-Frontend  >  HTML-Ereignisse

HTML-Ereignisse

WBOY
WBOYOriginal
2024-09-04 16:14:20843Durchsuche

Auf einer Webseite oder Website, die mit dem HTML-Skript (HyperText Markup Language) erstellt wurde, wird jede vom Benutzer und dem Web-Tool selbst ausgeführte Aktion als HTML-Ereignis bezeichnet. Die Beschreibung enthält sechs Arten von Attributen für jedes Ereignis: Fensterereignisattribut, Formularereignisattribut, Tastaturereignisattribut, Mausereignisattribut, Medienereignisattribut und Zwischenablageereignisattribut. Jedes dieser Ereignisattribute verfügt über spezifische dedizierte Attribute, die zum Abrufen der Details des HTML-Ereignisses verwendet werden.

Verschiedene Arten von HTML-Ereignissen

In HTML5 sind viele Ereignisattribute verfügbar, die hauptsächlich in 6 verschiedene Typen klassifiziert werden. Diese Attribute funktionieren mit der JavaScript-Sprache.

HTML-Ereignisse

  •  Windows-Ereignisattribute: Dies wird für die Aktion des Windows-Objekts bereitgestellt. Es funktioniert im Body-Tag  .
  •  Formularereignisattribute: Wenn der Benutzer eine Aktion im Formular ausführt, z. B. Daten eingeben, abbrechen, senden, funktionieren diese Ereignisattribute.
  •  Tastaturereignisattribute: Diese Tastaturereignisattribute werden für Tastaturaktionen und Benutzerinteraktionen verwendet.
  •  Mausereignisattribute: Mausereignisattribut, das für Mausaktionen wie Bewegen, Klicken, Drehen usw. verwendet wird.
  •  Ereignisattribute der Zwischenablage: Diese Ereignisattribute werden für die Aktion der Zwischenablage verwendet: Beispiel, Ausschneiden, Kopieren, Schädling.
  •  Medienereignisattribute: Dieses Ereignisattribut funktioniert bei Mediendateien wie Videos usw.

Beschreibung der Ereignisattribute

Hier finden Sie eine Erläuterung der unten aufgeführten Ereignisattribute im Detail:

1. Windows-Ereignisattribute

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.
Attribut

Beschreibung

onafterprint Dieses Skript wird jedoch ausgeführt, nachdem das Dokument gedruckt wurde. onbeforeprint Dieses Skript wird jedoch ausgeführt, bevor ein Dokument gedruckt wird. onbeforeunload Während vor dem entladenen Dokument dieses Skript funktioniert. onerror  Im Dokument tritt der Fehler auf, dann wird dieses Ereignis ausgeführt. onhashchange  Der Ankerteil der URL-Änderung im Dokument, als das Ereignis ausgeführt wurde. onload Wenn die erste Webseite vollständig geladen ist, wird dieses Ereignis ausgeführt. onmessage Im Dokument wird die Nachricht ausgeführt, die zu diesem Zeitpunkt aufgetreten ist. onoffline Wenn die Netzwerkverbindung nicht verfügbar ist und der Browser „Offline“ anzeigt, wird das Ereignis ausgeführt. online Wenn das Netzwerk im Browser verfügbar ist, wird das Ereignis ausgeführt. onpagehide Dieser Skriptakt; Wenn der Benutzer nicht an einer aktuellen Webseite arbeitet, kann eine dann aktuelle Seite ausgeblendet werden. onpageshow Dieses Skript fungiert zu dem Zeitpunkt, zu dem die aktuelle Webseite geladen wird. onpopstate Dieses Skript funktioniert automatisch im Browser bei einer Änderung des Verlaufsstatus. onresize Dieses Skript wird ausgeführt, wenn der Browser des Fensters die Größe ändert. im Speicher Wenn der Webspeicher des Benutzers aktualisiert wurde, wird das Ereignis ausgeführt. onunload Wenn die aktuelle Webseite des Benutzers nicht geladen wird oder das Fenster geschlossen ist, wird das Ereignis ausgeführt.

2. Formularereignisattribute

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. Tastaturereignisattribute

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. Mausereignisattribute

   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. Ereignisattribute der Zwischenablage

 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. Medienereignisattribute

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.

Fazit

Html-Ereignisse sind eine einfache Möglichkeit, Maßnahmen zu ergreifen und eine Schnittstelle zwischen Webbrowsern und Benutzern herzustellen. Benutzer können mühelos die Reaktion auf jede Aktion verfolgen. Beispielsweise Ausschneiden und Kopieren für die Zwischenablage, Verschieben und Klicken für die Maus, Schaltflächen für das Formular. Ereignisse machen Webanwendungen in Echtzeit und schaffen intelligente Arbeitssysteme.

Das obige ist der detaillierte Inhalt vonHTML-Ereignisse. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:HTML-BefehleNächster Artikel:HTML-Befehle