When you are developing using javascript it is often you get to the situation where you want to do something with javascript when the user clicks on the link. The problem is that when the user clicks on the link the browser will reload the window (and you don’t want that).

1.) Disable reload using HTML

<a href="#" onclick="myfunction();">do it</a>

With # start the on-page anchors, so this way you will specify that the link is an anchor (with no name) and the page will not be reloaded.

2.) The elegant way to disable links using javascript

<a href="javascript:return false;" onclick="if(confirm('Are you sure?'))myfunction();">do it</a>

For example these can be used to ask the user for deletion confirmation… and many other things of course.