JavaScript Tutorial/Event/Event Type
Содержание
Get mouse event type: click
<source lang="javascript">
<html> <head> <title>Mouse Events Example</title> <script type="text/javascript">
function handleEvent(oEvent) { var oTextbox = document.getElementById("txt1"); oTextbox.value += "\n" + oEvent.type;
}
</script> </head> <body>
Use your mouse to click and double click the red square.
<textarea id="txt1" rows="15" cols="50"></textarea>
</body> </html></source>
Get mouse event type: ondblclick
<source lang="javascript">
<html> <head> <title>Mouse Events Example</title> <script type="text/javascript">
function handleEvent(oEvent) { var oTextbox = document.getElementById("txt1"); oTextbox.value += "\n" + oEvent.type;
}
</script> </head> <body>
Use your mouse to click and double click the red square.
<textarea id="txt1" rows="15" cols="50"></textarea>
</body> </html></source>
Get mouse event type: onmousedown
<source lang="javascript">
<html> <head> <title>Mouse Events Example</title> <script type="text/javascript">
function handleEvent(oEvent) { var oTextbox = document.getElementById("txt1"); oTextbox.value += "\n" + oEvent.type;
}
</script> </head> <body>
Use your mouse to click and double click the red square.
<textarea id="txt1" rows="15" cols="50"></textarea>
</body> </html></source>
Get mouse event type: onmouseout
<source lang="javascript">
<html> <head> <title>Mouse Events Example</title> <script type="text/javascript">
function handleEvent(oEvent) { var oTextbox = document.getElementById("txt1"); oTextbox.value += "\n" + oEvent.type;
}
</script> </head> <body>
Use your mouse to click and double click the red square.
<textarea id="txt1" rows="15" cols="50"></textarea>
</body> </html></source>
Get mouse event type: onmouseover
<source lang="javascript">
<html> <head> <title>Mouse Events Example</title> <script type="text/javascript">
function handleEvent(oEvent) { var oTextbox = document.getElementById("txt1"); oTextbox.value += "\n" + oEvent.type;
}
</script> </head> <body>
Use your mouse to click and double click the red square.
<textarea id="txt1" rows="15" cols="50"></textarea>
</body> </html></source>
Get mouse event type: onmouseup
<source lang="javascript">
<html> <head> <title>Mouse Events Example</title> <script type="text/javascript">
function handleEvent(oEvent) { var oTextbox = document.getElementById("txt1"); oTextbox.value += "\n" + oEvent.type;
}
</script> </head> <body>
Use your mouse to click and double click the red square.
<textarea id="txt1" rows="15" cols="50"></textarea>
</body> </html></source>
Key event type
<source lang="javascript">
<html>
<head> <title>Key Events Example</title> <script type="text/javascript"> function handleEvent(oEvent) { var oTextbox = document.getElementById("txt1"); oTextbox.value += "\n>" + oEvent.type; } </script> </head> <body>
Type some characters into the first textbox.
<textarea id="txtInput" rows="15" cols="50" onkeydown="handleEvent(event)" onkeyup="handleEvent(event)" onkeypress="handleEvent(event)"></textarea>
<textarea id="txt1" rows="15" cols="50"></textarea>
</body>
</html></source>