In JavaScript:
object.onsearch = function(){
myScript};
This example uses the HTML DOM to assign an "onsearch" event to an input element.
The onsearch event is not supported in Internet Explorer, Firefox.
Write something in the search field and press "ENTER".
<!DOCTYPE html> <html> <body> <input type="search" id="myInput"> <p id="demo"></p> <script> document.getElementById("myInput").onsearch = function() {myFunction()}; function myFunction() {/*from ww w .ja va 2 s . c o m*/ var x = document.getElementById("myInput"); document.getElementById("demo").innerHTML = "You are searching for: " + x.value; } </script> </body> </html>
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |
Supported HTML tags: | <input type="search"> |