Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript / Onclick - Make the mouse cursor a hand when mousing over

I'm working with a voting button.

The button was a simple link, but the search engine spiders were crawling the pages and triggering false votes. So, I changed it to an onclick to make that stop.

However, after doing that, the buttons still work fine, but the mouse cursor no longer has the 'hand' pointer. It remains the arrow pointer when you mouse-over, so it's hard to tell that it's an actual functioning link.

To attempt to fix this, I added a style="cursor:default;", I also tried style="cursor:crosshair;" to try and change the cursor behavior, but it's not working. The cursor remains the pointer the whole time.

Here's my code:

<map id="vote_buttons" name="vote_buttons">
     <area shape="rect" alt="" coords="5,3,78,43" onClick="window.location='http://www.site.com/page.php?vote=Y'" style="cursor:default;" title="" />
     <area shape="rect" alt="" coords="83,3,160,44" onClick="window.location='http://www.site.com/page.php?vote=N'" style="cursor:pointer;" title="" />
     <area shape="default" nohref="nohref" alt="" />
</map>

What am I missing here to make this mouse-over look like a hand?

Thanks in advance as always.

like image 381
Kevin Avatar asked Feb 28 '13 23:02

Kevin


People also ask

How do I change the cursor when I hover over the button?

You can simply use the CSS cursor property with the value pointer to change the cursor into a hand pointer while hover over any element and not just hyperlink. In the following example when you place the cursor over the list item, it will change into a hand pointer instead of the default text selection cursor.

How do you change the cursor into a hand when a user hovers over a list item?

How to make the cursor to hand when a user hovers over a list item using CSS? Use CSS property to create cursor to hand when user hovers over the list of items. First create list of items using HTML <ul> and <li> tag and then use CSS property :hover to cursor:grab; to make cursor to hand hover the list of items.

Can JavaScript Move cursor?

You cannot move the actual mouse pointer in Javascript. You can, however move a pointer shaped image and pretend that you can. :-) Better yet, you can move a cat image around, following the mouse cursor, and try to use it to chase the cursor into the position you want.


3 Answers

You can do this in css!

just add this to the element you want the style.

cursor:pointer; 
like image 152
Josue Espinosa Avatar answered Oct 25 '22 06:10

Josue Espinosa


Actually I found the answer here: Cursor not changing to pointer in Usemap/area case

In your case, just add the href="javascript:void(0)" to each <area>.

Example: http://jsfiddle.net/yE5bQ/

like image 27
Justin Chmura Avatar answered Oct 25 '22 05:10

Justin Chmura


In your CSS put this:

#vote_buttons {
    cursor:hand;
}

This will make it so that your cursor turns into a hand while hovering over the button.

like image 23
Drew Avatar answered Oct 25 '22 07:10

Drew