WA
08-03-2002, 02:10 AM
Hi;
I have a question regarding passing the event object in NS6 hopefully someone can clarify. I have a function that has a few parameters, one of which is the event object. I wish to dynamically assign this function to an event handler, which itself is attached to a HTML element using script. My question is, how do I pass the event object into this function in this case? The below should work, but it doesn't:
Below code doesn't work in NS6
<form name="test">
<input type="text" name="test2">
</form>
<script>
function dothis(width,height,e){
alert(e)
}
document.test.test2.onkeypress=function(e){ dothis(5, 10, event); }
</script>
The above returns an "event" not defined error. I have no problem getting things to work if I simply defined the event handler using HTML. For example, the below works:
<input type="text" name="test2" onkeypress="dothis(5,10,event)">
Why is that?
I have a question regarding passing the event object in NS6 hopefully someone can clarify. I have a function that has a few parameters, one of which is the event object. I wish to dynamically assign this function to an event handler, which itself is attached to a HTML element using script. My question is, how do I pass the event object into this function in this case? The below should work, but it doesn't:
Below code doesn't work in NS6
<form name="test">
<input type="text" name="test2">
</form>
<script>
function dothis(width,height,e){
alert(e)
}
document.test.test2.onkeypress=function(e){ dothis(5, 10, event); }
</script>
The above returns an "event" not defined error. I have no problem getting things to work if I simply defined the event handler using HTML. For example, the below works:
<input type="text" name="test2" onkeypress="dothis(5,10,event)">
Why is that?