In my neck of the woods functions usually have arguments. For example f(r) = 3 + r is a nice function. f(5) = 8, f(-3) = 0. In JavaScript we could write it like this:
function f(r){
return (r + 3);
}
easy enough.
Now say we have a <INPUT element that has the onmouseover event defined like this:
<INPUT name="test"... onmouseover="Ja vaScript:alert( f(3));".../>
When the mouse goes over this elemnt you will get a message box that contains the value 6.
But what if we would like to remove the attribute and assign the onmouseover this way:
<INPUT name="test".../>
<script type="javascrip t">
<!-- Begin
document.getEle mentById('test' ).onmouseover = f
function f(r){
return (r+3);
}
// End -->
</script>
This won't work. I understand why it doesn't but I don't understand if assigning event handlers in this fashion REQUIRES argumentless functions. Is that right? Thanks.
--
George Hester
_______________ _______________ ____
function f(r){
return (r + 3);
}
easy enough.
Now say we have a <INPUT element that has the onmouseover event defined like this:
<INPUT name="test"... onmouseover="Ja vaScript:alert( f(3));".../>
When the mouse goes over this elemnt you will get a message box that contains the value 6.
But what if we would like to remove the attribute and assign the onmouseover this way:
<INPUT name="test".../>
<script type="javascrip t">
<!-- Begin
document.getEle mentById('test' ).onmouseover = f
function f(r){
return (r+3);
}
// End -->
</script>
This won't work. I understand why it doesn't but I don't understand if assigning event handlers in this fashion REQUIRES argumentless functions. Is that right? Thanks.
--
George Hester
_______________ _______________ ____
Comment