views:

30

answers:

1

hi i want to attach the image or div element to the cursor in firefox in my application when mouseover the some element than image will be attached to cursor.

thanks rahul

+1  A: 

You can use an image as the mouse cursor fairly easily using CSS.

div {
    cursor: url(mypointer.gif), auto;
}

This will make the cursor change to the graphic you specify when you hover over a div tag. You will need to change the CSS selector in the example to match the parts of your page that you want to have the custom mouse pointer. (you'll also obviously need to create the graphic and reference the correct name for it in the CSS code).

Note that there are some restrictions on this (browser compatibility, size of image, etc). This page will tell you more: http://www.quirksmode.org/css/cursor.html (scroll down to the bit about the URL style to see it in use and further info)

If you want more than that (eg a whole div following the mouse, or a bigger graphic than supported by the above, then you'll need to use Javascript. Your best option is to use a javascript library like JQuery with an appropriate plug-in.

Here is a link to a JQuery plug-in that will allow you to set up tooltips with text and images. Demos and example code are included. You'll need to download JQuery and this plug-in, and add them to your site.

Spudley
does this cursor in css works in firefox ?
Rahul Mehta
@Spudley does this cursor in css works in firefox ?
Rahul Mehta
@Rahul -- yes it does, but see the link I gave you; it details the browser compatability for this feature.
Spudley
but i have tried in firefox it doesnt work can give me sample code which works
Rahul Mehta
i want to do this ..
Rahul Mehta
I've added further info to the answer. Hope that helps.
Spudley