|
Never attach JavaScript insiide the href attribute.
Best is to not jumble any of the JavaScript in the HTML at all and put ALL the JavaScript in the external file.
<a id="a1" href="nojs.htm">click here</a>
and in the external HTML
document.getElementById('a1').onclick = function() {..... ; return false;}
the code for your function goes in place of the ..... in the above command that is in the external JavaScript file.
You attach JavaScript in the external file to HTML in the web page using the id of the element you want to attach it to (or in some cases class names if the same code is to be attached to multiple elements
The code suggested by DMN was considered to be bad practice in Netscape 2 and worse practice in every browser since then.
|