javascript - What's the effect of adding 'return false' to a click event listener? -


many times i've seen links these in html pages:

<a href='#' onclick='somefunc(3.1415926); return false;'>click here !</a> 

what's effect of return false in there?

also, don't see in buttons.

is specified anywhere? in spec in w3.org?

the return value of event handler determines whether or not default browser behaviour should take place well. in case of clicking on links, following link, difference noticeable in form submit handlers, can cancel form submission if user has made mistake entering information.

i don't believe there w3c specification this. ancient javascript interfaces have been given nickname "dom 0", , unspecified. may have luck reading old netscape 2 documentation.

the modern way of achieving effect call event.preventdefault(), , specified in the dom 2 events specification.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -