image 对象对键盘没有反应?
我只是想当键盘按下时,
image对键盘有响应,请大虾看看有什么问题:用image onkeydwon 事件
:
<html>
<body>
<script type="image/javascript" for="image" event="onkeydown">
function noNumbers(e)
{
var keynum
var keychar
var numcheck
if(window.event) // IE
{
keynum = e.keyCode
alert (keynum)
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which
alert (keynum)
}
alert ("the sample.")
keychar = String.fromCharCode(keynum)
numcheck = /d/
return !numcheck.test(keychar)
}
</script>
<body>
<p><img name="image1" src="images.jpg" width="256" height="128"> </p>
<input type="image" value='*' onkeydown="return noNumbers(event)">
</body>
</html>