Musings of a Philadelphia Physician who has served the community for six decades

Return to Home

Related Topics

Website Development
The website technology supporting Philadelphia Reflections is PHP, MySQL and DHTML. The web hosting service is Internet Planners. The development of this website has provided an opportunity to learn new technology, to try out different techniques for getting noticed by the search engines and the trials and tribulations of dealing with malicious hackers and spammers who range from the annoying to the abusive. This collection of articles documents some of our experiences and we hope that people surfing the web looking for solutions to problems we've encountered will benefit.

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 popular 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 for HTML encoding.


instead of one or the other use both, then it works in FF

this is my example;

a href="javascript:return openCenteredWindow('index/process.php');" onclick="return openCenteredWindow('index/process.php');"
Posted by: this is how   |   Oct 20, 2008 3:46 AM
"in the FF"?

Firefox? Works perfectly in mine, what version are you using? Do you have JavaScript enabled?
Posted by: g4   |   Jun 17, 2008 10:02 AM
Unfortunately in the FF it doesn't work
Posted by: Maxim   |   Jun 17, 2008 4:39 AM

Please Let Us Know What You Think

(HTML tags provide better formatting)

Because of robot spam we ask you to confirm your comment: we will send you an email containing a link to click. We apologize for this inconvenience but this ensures the quality of the comments. (Your email will not be displayed.)
Thank you.