AdNow

loading...

Atributos de eventos HTML

Atributos de eventos HTML


Atributos de eventos globales

HTML 4 agregó la capacidad de permitir que los eventos desencadenen acciones en un navegador, como iniciar un JavaScript cuando un usuario hace clic en un elemento.
Para obtener más información sobre la programación de eventos, visite nuestro tutorial de JavaScript .
A continuación se muestran los atributos de eventos globales que se pueden agregar a los elementos HTML para definir acciones de eventos.
= Nuevos atributos de evento en HTML5.

Atributos de evento de ventana

Eventos activados para el objeto ventana (se aplica a la etiqueta <body>):
AttributeValueDescription
onafterprintscriptScript to be run after the document is printed
onbeforeprintscriptScript to be run before the document is printed
onbeforeunloadscriptScript to be run when the document is about to be unloaded
onerrorscriptScript to be run when an error occurs
onhashchangescriptScript to be run when there has been changes to the anchor part of the a URL
onloadscriptFires after the page is finished loading
onmessagescriptScript to be run when the message is triggered
onofflinescriptScript to be run when the browser starts to work offline
ononlinescriptScript to be run when the browser starts to work online
onpagehidescriptScript to be run when a user navigates away from a page
onpageshowscriptScript to be run when a user navigates to a page
onpopstatescriptScript to be run when the window's history changes
onresizescriptFires when the browser window is resized
onstoragescriptScript to be run when a Web Storage area is updated
onunloadscriptFires once a page has unloaded (or the browser window has been closed)


Eventos de formulario

Eventos desencadenados por acciones dentro de un formulario HTML (se aplica a casi todos los elementos HTML, pero es el más utilizado en los elementos de formulario):
AttributeValueDescription
onblurscriptFires the moment that the element loses focus
onchangescriptFires the moment when the value of the element is changed
oncontextmenuscriptScript to be run when a context menu is triggered
onfocusscriptFires the moment when the element gets focus
oninputscriptScript to be run when an element gets user input
oninvalidscriptScript to be run when an element is invalid
onresetscriptFires when the Reset button in a form is clicked
onsearchscriptFires when the user writes something in a search field (for <input="search">)
onselectscriptFires after some text has been selected in an element
onsubmitscriptFires when a form is submitted

Eventos de teclado

AttributeValueDescription
onkeydownscriptFires when a user is pressing a key
onkeypressscriptFires when a user presses a key
onkeyupscriptFires when a user releases a key

Eventos del mouse

AttributeValueDescription
onclickscriptFires on a mouse click on the element
ondblclickscriptFires on a mouse double-click on the element
onmousedownscriptFires when a mouse button is pressed down on an element
onmousemovescriptFires when the mouse pointer is moving while it is over an element
onmouseoutscriptFires when the mouse pointer moves out of an element
onmouseoverscriptFires when the mouse pointer moves over an element
onmouseupscriptFires when a mouse button is released over an element
onmousewheelscriptDeprecated. Use the onwheel attribute instead
onwheelscriptFires when the mouse wheel rolls up or down over an element

Arrastrar eventos

AttributeValueDescription
ondragscriptScript to be run when an element is dragged
ondragendscriptScript to be run at the end of a drag operation
ondragenterscriptScript to be run when an element has been dragged to a valid drop target
ondragleavescriptScript to be run when an element leaves a valid drop target
ondragoverscriptScript to be run when an element is being dragged over a valid drop target
ondragstartscriptScript to be run at the start of a drag operation
ondropscriptScript to be run when dragged element is being dropped
onscrollscriptScript to be run when an element's scrollbar is being scrolled

Eventos de portapapeles

AttributeValueDescription
oncopyscriptFires when the user copies the content of an element
oncutscriptFires when the user cuts the content of an element
onpastescriptFires when the user pastes some content in an element

Eventos de medios

Eventos activados por medios como videos, imágenes y audio (se aplica a todos los elementos HTML, pero es más común en elementos multimedia, como <audio>, <embed>, <img>, <object> y <video>).
Consejo: mire nuestra referencia de DOM HTML de audio y video para más información.
AttributeValueDescription
onabortscriptScript to be run on abort
oncanplayscriptScript to be run when a file is ready to start playing (when it has buffered enough to begin)
oncanplaythroughscriptScript to be run when a file can be played all the way to the end without pausing for buffering
oncuechangescriptScript to be run when the cue changes in a <track> element
ondurationchangescriptScript to be run when the length of the media changes
onemptiedscriptScript to be run when something bad happens and the file is suddenly unavailable (like unexpectedly disconnects)
onendedscriptScript to be run when the media has reach the end (a useful event for messages like "thanks for listening")
onerrorscriptScript to be run when an error occurs when the file is being loaded
onloadeddatascriptScript to be run when media data is loaded
onloadedmetadatascriptScript to be run when meta data (like dimensions and duration) are loaded
onloadstartscriptScript to be run just as the file begins to load before anything is actually loaded
onpausescriptScript to be run when the media is paused either by the user or programmatically
onplayscriptScript to be run when the media is ready to start playing
onplayingscriptScript to be run when the media actually has started playing
onprogressscriptScript to be run when the browser is in the process of getting the media data
onratechangescriptScript to be run each time the playback rate changes (like when a user switches to a slow motion or fast forward mode)
onseekedscriptScript to be run when the seeking attribute is set to false indicating that seeking has ended
onseekingscriptScript to be run when the seeking attribute is set to true indicating that seeking is active
onstalledscriptScript to be run when the browser is unable to fetch the media data for whatever reason
onsuspendscriptScript to be run when fetching the media data is stopped before it is completely loaded for whatever reason
ontimeupdatescriptScript to be run when the playing position has changed (like when the user fast forwards to a different point in the media)
onvolumechangescriptScript to be run each time the volume is changed which (includes setting the volume to "mute")
onwaitingscriptScript to be run when the media has paused but is expected to resume (like when the media pauses to buffer more data)

Eventos diversos

AttributeValueDescription
onshowscriptFires when a <menu> element is shown as a context menu
ontogglescriptFires when the user opens or closes the <details> element

Formulario de contacto

Nombre

Correo electrónico *

Mensaje *

Entradas más populares de este blog

Listado pasaporte y cedulas SAIME 2018

Etiqueta HTML < abbr >

HTML < a > tag

Visitas a este blog