How to trigger Javascript attached to links

People are used to clicking on links within Web pages. That makes them ideal things to attach JavaScript to. However, if you just add on onclick event there can be problems so instead you do it this way:

<a href="javascript:fred();">Click here to run the function fred.<>
        
submit to reddit Delicious Tweet