Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

onsearch event

onsearch event

Event Object Reference Event Object

Example

Execute JavaScript when a search is submitted:

Try it »


Definition and Usage

The onsearch event is triggered when the user presses the "ENTER" key or clicks the "x (search)" button of the type="search" element.


Browser support

The numbers in the table indicate the version number of the first browser to support the event.

Events
onsearch Yes Not supported Not supported Yes 15.0

Syntax

In HTML:

<

element

onsearch="

myScript

">

Try it

In JavaScript:

object

.onsearch=function(){

myScript

};

Try it

In JavaScript, use the addEventListener() method:

object

.addEventListener("search",

myScript

);

Try it

Note: Internet Explorer 8 and earlier IE versions do not support addEventListener() method.


Technical Details

Does it support bubbling: Yes
Is it cancelable: No
Event type: Event
Supported HTML tags:

Event Object Reference Event Object