Many times I’ve seen links like these in HTML pages:
<a href='#' onclick='someFunc(3.1415926); return false;'>Click here !</a>
What’s the effect of the
return false in there?
Also, I don’t usually see that in buttons.
Is this specified anywhere? In some spec in w3.org?
Good Answer: 👌👌👌
The return value of an event handler determines whether or not the default browser behaviour should take place as well. In the case of clicking on links, this would be following the link, but the difference is most noticeable in form submit handlers, where you can cancel a form submission if the user has made a mistake entering the information.
The modern way of achieving this effect is to call
event.preventDefault(), and this is specified in the DOM 2 Events specification.
Read More: 👉 https://stackoverflow.com/questions/128923/whats-the-effect-of-adding-return-false-to-a-click-event-listener