• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 352
  • Last Modified:

Javascript: How to prevent an href="" on a onMouseOver event of an image to do nothing when the user clicks on the image?

I have this javascript call on a onMouseOver event of an image
<a href="" onMouseOver="vShowThis(1);" onMouseOut="vHideThis();return true;">
      <img border="0" src="images/small/que.gif" width="19" height="19">
</a>

How do I prevent the click to open a "" blank page?
0
AkisC
Asked:
AkisC
  • 4
  • 3
1 Solution
 
Ashutosh VyasFounder, InitQubeCommented:
If you do not want user to navigate anywhere when he clicks the image, why do you need anchor tag on it then?
0
 
AkisCAuthor Commented:
My javascript expirience counts some 20 days.
I read on the internet that if you want to show shomething when the mouse is over an image then you have to use the code like above... I copy/pasted it from another page

Is there a better way to handle a onMouse even on this image?
<img border="0" src="images/small/que.gif" width="19" height="19">

Thank you

0
 
Michel PlungjanIT ExpertCommented:
<a href="#"  onClick="return false"
onMouseOver="vShowThis(0);" onMouseOut="vHideThis();return true;"><img
border="0" src="images/small/que.gif" width="19" height="19"></a>

(also loose the whitespace if you have underline)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Michel PlungjanIT ExpertCommented:
And the reason to put it in a link is
1. screen readers (you would want an ALT on the image or a TITLE on the link)
2. automatic hand/pointer when the mouse is hovering
3. backwards compatibility with old browsers or new pared down browsers on smartphones for example
0
 
AkisCAuthor Commented:
Hi mplungjan
Did I award 500x4? This was my intention
I was on the phone and clicked {ok} without paying attention.
Please tell me?
0
 
Michel PlungjanIT ExpertCommented:
Yes, thanks
0
 
AkisCAuthor Commented:
Your help is much appreciated!
I thank you for your precious time spend for my problem
0
 
Michel PlungjanIT ExpertCommented:
You are welcome
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now