ConfusedOfLife
04-09-2003, 01:02 PM
Hi,
this code doesn't have any problem in IE, however, it doesn't work in Mozilla and it doesn't give me any error message.
<body>
<input id="damn" type="Text">
<script>
document.getElementById("damn").onkeydown = function()
{
keydown( event, this );
}
document.getElementById("damn").onkeyup = function()
{
keyup( event, this );
}
function keyup( oEvent, element )
{
var key = oEvent.keyCode;
alert(key);
}
function keydown( oEvent, element )
{
var key = oEvent.keyCode;
alert(key);
}
</script>
As you see, I'm only trying to send some arguments to my functions, but because the syntax doesn't let me do it directly, I have to use an anonymous function. Is there any way I can fix it? I can't use onkeydown/up as the input's attributes directly in the HTML.
this code doesn't have any problem in IE, however, it doesn't work in Mozilla and it doesn't give me any error message.
<body>
<input id="damn" type="Text">
<script>
document.getElementById("damn").onkeydown = function()
{
keydown( event, this );
}
document.getElementById("damn").onkeyup = function()
{
keyup( event, this );
}
function keyup( oEvent, element )
{
var key = oEvent.keyCode;
alert(key);
}
function keydown( oEvent, element )
{
var key = oEvent.keyCode;
alert(key);
}
</script>
As you see, I'm only trying to send some arguments to my functions, but because the syntax doesn't let me do it directly, I have to use an anonymous function. Is there any way I can fix it? I can't use onkeydown/up as the input's attributes directly in the HTML.