To prevent the default behavior we can use event.preventDefault() method of the event. Older browsers (ie 7 and below) dont support this method, so we have to use onclick="return false;"
Note:
I added simple text with in the link, to demonstrate the image click is disabled but when we click the text, the anchor click gets activated.
function onimgclick(event) {
if(event.preventDefault)
event.preventDefault();
else {
return false;
}
}
And the html markup should be
<a href="google.com"><img onclick="return onimgclick(event)" src="sample.png"></img> HI</a>