<html>
<body>
<p>此示例使用 HTML DOM 将“onsearch”事件分配给输入元素。</p>
<p>在搜索字段中输入内容,然后按"ENTER"。</p>
<input type="search" id="myInput">
<p><strong>注意:</strong> Internet Explorer、Firefox 或 Opera 12 及更早版本不支持 onsearch 事件。</p>
<p id="demo"></p>
<script>
document.getElementById("myInput").onsearch = function() {myFunction()};
function myFunction() {
var x = document.getElementById("myInput");
document.getElementById("demo").innerHTML = "您正在寻找:" + x.value;
}
</script>
</body>
</html>