Disabling the Default Action
Friday May 22, 2009
When you attach an action with JavaScript you don't necessarily want the original action to be performed too.
There are a number of objects on a web page that have their own default action attached that will be performed when your visitors interact with that object (eg. by clicking a link or submitting a form). When you attach Javascript processing to those objects there will be times when you don't want that default action to occur. You can use Javascript to turn off that default action.
Disabling the Default Action


Why did you not make your events unobtrusive?
If you are going to profess that unobtrusive JavaScript is the way to go, then shouldn’t all of your tutorials and articles feature unobtrusive JavaScript? Or is it do as Chappy says, not as Chappy does? Or maybe your just lazy. Or maybe both.
The scripts on this site have been written by me over the past ten years (including those I originally wrote before I started to write here). All of those I have written in the past two years have been completely unobtrusive and I have modified some of the earlier ones to also be less obtrusive than they were when I originally wrote them. If you have a spare five years tucked away in your back pocket then please send it my way so that I can use it to rewrite all the scripts I have ever written to be the way they would be if I wrote them now.
Also there are still other people who haven’t converted all their scripts to be unobtrusive and sometimes they need to make a quick change to fix an error and so articles on how to make such changes are still appropriate.