HTML Basic
HTML Reference
- HTML Tags
- HTML Deprecated Tags
- HTML Events
- HTML Attributes
- accept
- accept-charset
- accesskey
- action
- align
- alt
- as
- async
- autocomplete
- autofocus
- autoplay
- bgcolor
- border
- charset
- checked
- cite
- class
- color
- cols
- colspan
- content
- contenteditable
- controls
- coords
- data
- data-*
- datetime
- default
- defer
- dir
- dirname
- disabled
- download
- draggable
- enctype
- enterkeyhint
- for
- form
- formaction
- headers
- height
- hidden
- high
- href
- hreflang
- 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 Global Attributes
- HTML Status Code
- HTML Language Code
- HTML Country Code
- HTML Charset
- MIME Types
HTML onseeking Attribute
Photo Credit to CodeToFun
🙋 Introduction
The onseeking
attribute is a useful feature in HTML that allows developers to specify a JavaScript function to be executed when the seeking state of an audio or video element changes.
This attribute is a part of the event attributes in HTML, providing a way to respond to seeking-related events during media playback.
🎯 Purpose of onseeking
The primary purpose of the onseeking
attribute is to enable developers to define custom behavior when a user seeks to a different position in an audio or video file.
This can be valuable for creating interactive and responsive media players on web pages.
💎 Values
The onseeking
attribute expects a JavaScript function as its value. This function is executed when the seeking event occurs. For example:
<video controls onseeking="handleSeekingEvent()">
<source src="example.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
🧠 How it Works
In this example, the handleSeekingEvent() function will be called when the user initiates seeking in the video.
🔄 Dynamic Values with JavaScript
Similar to other event attributes, you can dynamically set the onseeking
attribute using JavaScript.
This is beneficial when you want to attach or change event handlers based on certain conditions or user interactions. Here's an illustration:
<script>
// Dynamically set onseeking event handler
function handleDynamicSeeking() {
console.log("Seeking event detected!");
// Your custom logic here
}
// Assign the event handler to a video element
document.getElementById("dynamicVideo").onseeking = handleDynamicSeeking;
</script>
🧠 How it Works
In this script, the handleDynamicSeeking function is assigned to the onseeking
attribute of a video element with the id dynamicVideo. This allows you to execute custom logic when the seeking event occurs.
🏆 Best Practices
- Use the
onseeking
attribute when you need to perform specific actions in response to seeking events in media elements. - Keep the event handler functions concise and focused on the intended behavior to maintain clean and maintainable code.
- Test your media-related functionality across different browsers to ensure consistent behavior.
🎉 Conclusion
The onseeking
attribute provides a powerful way to enhance the interactivity of audio and video elements on your web page.
By understanding and utilizing this attribute, you can create more engaging and responsive media experiences for your users.
👨💻 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 onseeking Attribute), please comment here. I will help you immediately.