Evertjan. wrote:
<snip>
> The below shows no difference between
>
> onclick='f();return false;'>
> and
> onclick='return f();'>
<snip>
In the event that an exception is thrown during the execution of the -
f - function the fact that it is not caught in the event handler means
that the event handler will also throw an exception and so the final -
return false; - will never be executed in the first variant. There is
little practical difference between the two.
The second is probably the preferable formulation because it allows
the - f - function to make intelligent decisions about whether the event
handler will cancel the default action or not; cancelling it in the
event of successful execution of the function and not cancelling it if
the - f - function can anticipate and avoid errors, detect unsuccessful
action (such as the - window.open - call returning null) or catch but
not handle any exceptions thrown. Thus allowing the default action of
the event to facilitate fall-back in a controlled manor.
Richard.
Received on Mon May 1 05:28:20 2006