HTML Topics
- HTML Intro
- HTML Basic
- HTML Editors
- HTML CSS
- HTML Tags
- HTML Deprecated Tags
- HTML Events
- HTML Event Attributes
- HTML Global Attributes
- HTML Attributes
- abbr
- accept
- accept-charset
- accesskey
- action
- align
- alt
- archive
- as
- async
- autocapitalize
- autocomplete
- autofocus
- autoplay
- axis
- bgcolor
- border
- cellpadding
- cellspacing
- char
- charoff
- charset
- checked
- cite
- class
- classid
- codebase
- codetype
- color
- cols
- colspan
- compact
- content
- contenteditable
- controls
- coords
- crossorigin
- data
- data-*
- datetime
- declare
- default
- defer
- dir
- dirname
- disabled
- download
- draggable
- enctype
- enterkeyhint
- for
- form
- formaction
- formenctype
- formmethod
- formnovalidate
- formtarget
- frame
- frameborder
- frameset
- headers
- height
- hidden
- high
- href
- hreflang
- hspace
- http-equiv
- id
- inert
- inputmode
- ismap
- kind
- label
- lang
- list
- loop
- low
- max
- maxlength
- media
- method
- min
- multiple
- muted
- name
- novalidate
- onabort
- onafterprint
- onbeforeprint
- onbeforeunload
- onblur
- oncanplay
- oncanplaythrough
- onchange
- onclick
- oncontextmenu
- oncopy
- oncuechange
- oncut
- ondblclick
- ondrag
- ondragend
- ondragenter
- ondragleave
- ondragover
- ondragstart
- ondrop
- ondurationchange
- onemptied
- onended
- onerror
- onfocus
- onhashchange
- oninput
- oninvalid
- onkeydown
- onkeypress
- onkeyup
- onload
- onloadeddata
- onloadedmetadata
- onloadstart
- onmousedown
- onmousemove
- onmouseout
- onmouseover
- onmouseup
- onmousewheel
- onoffline
- ononline
- onpagehide
- onpageshow
- onpaste
- onpause
- onplay
- onplaying
- onpopstate
- onprogress
- onratechange
- onreset
- onresize
- onscroll
- onsearch
- onseeked
- onseeking
- onselect
- onstalled
- onstorage
- onsubmit
- onsuspend
- ontimeupdate
- ontoggle
- onunload
- onvolumechange
- onwaiting
- onwheel
- open
- optimum
- pattern
- placeholder
- popover
- popovertarget
- popovertargetaction
- poster
- preload
- readonly
- rel
- required
- reversed
- rows
- rowspan
- sandbox
- scope
- selected
- shape
- size
- sizes
- span
- spellcheck
- src
- srcdoc
- srclang
- srcset
- start
- step
- style
- tabindex
- target
- title
- translate
- type
- usemap
- value
- width
- wrap
- HTML Comments
- HTML Entity
- HTML Head
- HTML Form
- HTML IndexedDB
- HTML Drag & Drop
- HTML Geolocation
- HTML Canvas
- HTML Status Code
- HTML Language Code
- HTML Country Code
- HTML Charset
- MIME Types
HTML onseeked Attribute
Photo Credit to CodeToFun
🙋 Introduction
The onseeked
attribute is an event handler attribute in HTML that specifies a script to run when a seek operation (a change in the position of the playback) has ended in an audio or video element.
This attribute provides developers with the ability to execute custom JavaScript code in response to the completion of a seek operation.
🎯 Purpose of onseeked
The main purpose of the onseeked
attribute is to allow developers to define custom behavior or actions that should occur once a seek operation has been successfully completed.
This can be useful for scenarios where you want to synchronize additional actions or events with the seeking process in multimedia elements.
💎 Values
As an event handler attribute, the onseeked
attribute takes a JavaScript function as its value. This function will be executed when the seeked event occurs. Here's a simple example:
<video controls onseeked="seekedHandler()">
<source src="example.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
<script>
function seekedHandler() {
console.log("Seek operation completed!");
// Add your custom actions here
}
</script>
🧠 How it Works
In this example, the onseeked
attribute is assigned the value seekedHandler(), which is a JavaScript function that will be called when the seeked event occurs.
🔄 Dynamic Values with JavaScript
Similar to other event handler attributes, you can dynamically set the onseeked
attribute using JavaScript.
This allows you to change the behavior of the seeked event handler based on certain conditions or user interactions. Here's an illustration:
<script>
// Dynamically set onseeked event handler
document.getElementById("myVideo").onseeked = function() {
console.log("Dynamic seeked event handler executed.");
// Add your dynamic actions here
};
</script>
🧠 How it Works
In this script, the onseeked
attribute is dynamically set for a video element with the id myVideo. The assigned function will be executed when the seeked event occurs.
🏆 Best Practices
- Use the
onseeked
attribute when you need to perform custom actions or updates after a seek operation in multimedia elements. - Keep the event handler functions concise and focused on the specific actions you want to take in response to the seeked event.
- Test your implementation across different browsers to ensure consistent behavior.
🎉 Conclusion
The onseeked
attribute provides a valuable tool for developers working with multimedia elements, allowing them to respond to seek operations with custom JavaScript code.
By understanding and utilizing this attribute, you can enhance the interactivity and responsiveness of your audio and video elements.
👨💻 Join our Community:
Author
For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.
Buy me a coffee to make codetofun.com free for everyone.
Buy me a Coffee
If you have any doubts regarding this article (HTML onseeked Attribute), please comment here. I will help you immediately.