HTML Anchor without an HREF?
Sometimes I want to execute a JavaScript function when a user clicks a link, but nothing else.
If I omit the href entirely, the cursor doesn't change and some browsers don't recognize the text as a link:
<a onclick="function();">
If I include the pound sign, which seems to be a very poopular trick, I get sent to the top of the current page, which messes up both History and the backspace button; to say nothing of the fact that I don't want to jump to the top of the page:
<a href="#" onclick="function();">
Including the function in the href and omitting the onclick seems to be the answer to my specific problem:
<a href="javascript: function();">
Once again, my thanks to http://centricle.com/tools/html-entities/ for HTML encoding.
(1429)







