The onsearch attribute is an event handler for the search event on <input type="search">. In supporting browsers it runs when the user initiates a search — for example pressing Enter — or clears the field with the built-in clear control.
Read the query from this.value (or event.target.value). For portable live filtering, prefer oninput / onchange or form onsubmit.
Non-standard.
MDN marks the search event as not standardized. It is missing in Firefox. Study it for Chromium/WebKit behavior; ship portable listeners for production.
Related non-standard: incremental.
On WebKit/Blink, incremental can fire debounced search events while typing. Do not rely on it cross-browser.
Syntax
HTML Syntax
syntax.html
<input type="search" onsearch="handler">
Modern equivalent (where supported): input.addEventListener("search", function (event) { … });. Portable alternative: listen for input or change.
Values
Attribute Values
The value is a script (event handler code). Typical triggers in supporting UAs:
input updates on every change — works in all modern browsers.
search adds Enter/clear behavior where supported.
Same UI (type="search") for the clear control and search keyboard.
Production tip: treat search as optional enhancement.
Edge Cases & Pitfalls
The main risk is assuming search exists everywhere.
firefox
No search event in Firefox
Enter and typing will not fire onsearch there. Use input / form submit.
type
Only meaningful on type="search"
Other input types do not get this search UX or event.
incremental
incremental is also non-standard
Live-as-you-type via search is WebKit/Blink-oriented. Prefer input + debounce.
cancel
Event is not cancelable
You cannot preventDefault() the search event to block it.
form
Enter may also submit a form
Inside a <form>, handle submit if navigation or a GET search is intended.
Compatibility
Browser Support
onsearch / the search event is a non-standard HTMLInputElement feature. It is not a Node.js, Deno, or Bun API.
✓ Non-standard
onsearch
Available in Chromium-based browsers and historically Safari/WebKit. Not supported in Firefox. Prefer input/change/submit for cross-browser apps.
~78%Global support (approx.)
Google ChromeYes
Supported
Mozilla FirefoxNo
Not supported
Apple SafariPartial*
Historically yes; verify current
Microsoft Edge79+
Supported (Chromium)
OperaYes
Supported
Samsung InternetYes
Supported
Internet ExplorerNo
Not supported
onsearchPartial / non-standard
Bottom line: Fine to study and enhance Chromium/WebKit UIs. Do not rely on onsearch alone for production search boxes.
Remember
Key Takeaways
Role: handle search initiation on type="search".
Non-standard — missing in Firefox.
Preferinput / form submit for portability.
incremental is also non-standard (WebKit/Blink).
One line:onsearch is a non-standard Enter/clear hook for search inputs — use input when you need every browser.
Frequently Asked Questions
It is an event handler for the search event on <input type="search">. Supporting browsers fire it when the user initiates a search (for example pressing Enter) or clears the field with the clear control.
No. MDN marks the search event as non-standard. It is not in Firefox. Prefer oninput, onchange, or form submit for portable code.
Typically on Enter while focused, when using the clear (×) control (value becomes ""), and — if the non-standard incremental attribute is set — after typing pauses in WebKit/Blink.
A non-standard WebKit/Blink attribute. When present, the browser sends debounced search events while the user types for live filtering.
Use <input type="search"> for UX, then listen with addEventListener("input", …) and/or submit the form. Optionally add search only as an enhancement where supported.
No. The search event is not cancelable according to MDN.