<html>
<head>
<script type="text/javascript">
function color(color)
{
document.forms[0].myInput.style.background=color
}
</script>
</head>
<body>
<form>
请编写一条消息:<br />
<input
type="text"
onkeydown="color('red')"
onkeyup="color('blue')"
name="myInput" size="20">
</form>
</body>
</html>