When most people first think about adding an onclick event handler to their web page they immediately think of adding it to an <a> tag. This gives a piece of code that often looks like:
<a href="#" onclick="dosomething(); return false;">
What many people do not realise is that the onclick event handler can be added to any HTML tag in the web page in order to interact when your visitor clicks on that content. So if you want something to run when people click on an image you can use:
<img src="myimg.gif" onclick="dosomething()">
If you want to run something when people click on some text you can use:
<span onclick="dosomething()">some text</span>
Of course these don't give the automatic visual clue that there will be a response if your visitor clicks on them the way that a link does but you can add that visual clue easily enough yourself by styling the image or span appropriately.
The other thing to note about these ways of attaching the onclick event handler is that they do not require the "return false" because there is no default action that will happen when the element is clicked on that needs to be disabled.
The easiest way to do this is to replace the onclick in the HTML with an id that will make it easy to attach the event handler to the appropriate spot in the HTML. So our HTML might now contain one of these statements:
< img src="myimg.gif" id="img1"> <span id="sp1">some text</span>
document.getElementById('img1').onclick = dosomething; document.getElementById('sp1').onclick = dosomething;