473,508 Members | 2,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom cursor using Javascript in Firefox

KeredDrahcir
426 Contributor
I'm trying to use an onmouseover event to change the cursor to a custom .cur image.
onMouseOver="this.style.cursor='icons/cursor.cur';"
The above code works fine in IE but not in Firefox. It's important the users know where they can click.
Could anyone help please?
Nov 24 '09 #1
19 7236
gits
5,390 Recognized Expert Moderator Expert
you might use:
Expand|Select|Wrap|Line Numbers
  1. this.style.cursor = 'pointer';
kind regards
Nov 24 '09 #2
drhowarddrfine
7,435 Recognized Expert Expert
Because IE does it wrong like everything else. It should be:
this.style.cursor = "url(icons/cursor.cur)";

And onmouseover should be lower case in xhtml, at least.
Nov 25 '09 #3
KeredDrahcir
426 Contributor
Thanks for the reply drhowarddrfine but I did try that code before I came here. I've tried it again and it still doesn't seem to work. I see you've put double quotes around the path to find the cursor. Since onmouseover goes in quotes could that cause a problem?
Nov 25 '09 #4
gits
5,390 Recognized Expert Moderator Expert
of course ... either use single quotes inside the doubles or escape the inside double quotes:
Expand|Select|Wrap|Line Numbers
  1. onmouseover="this.style.cursor=\"url(icons/cursor.cur)\";"
  2.  
regards
Nov 25 '09 #5
KeredDrahcir
426 Contributor
I've tried that and it still doesn't work.
Dec 1 '09 #6
gits
5,390 Recognized Expert Moderator Expert
does it work with any other 'webaware' image like a gif or jpeg?

kind regards
Dec 3 '09 #7
KeredDrahcir
426 Contributor
I'll try that. Can it be done in Firefox? JavaScript Kit say it's IE only although the page was talking about NS so it was proabaly quite old.
Dec 3 '09 #8
gits
5,390 Recognized Expert Moderator Expert
never tried it ... but the following:
Expand|Select|Wrap|Line Numbers
  1. onmouseover="this.style.cursor='pointer';"
works
Dec 3 '09 #9
KeredDrahcir
426 Contributor
I can get the cursor as a pointer but the image still doesn't work. I've tried it as a gif and all I get (as before) is the text cursor.
I've got the pointer working elshwere on the same page.
Dec 4 '09 #10
gits
5,390 Recognized Expert Moderator Expert
so using the pointer should be sufficient ... since it shows the standard 'here you can click' cursor? ... i'm not quite sure whether I would use another cursor or image except I would need it for a browser based game ... or why is it essential to have another custom cursor?

kind regards
Dec 5 '09 #11
KeredDrahcir
426 Contributor
I can use the pointer but using the custom cursor just helps remind us whether we are logged in as user or administrator.
It don't suppose it's essential but it does improve the look. I just thought it should be possible.
Dec 7 '09 #12
acoder
16,027 Recognized Expert Moderator MVP
I may be wrong, but I think you need to specify a default, e.g. "auto" or "default" for the custom cursor to work, e.g.
Expand|Select|Wrap|Line Numbers
  1. onmouseover="this.style.cursor=\"url(icons/cursor.cur),auto\";"
You could also consider using CSS only with "hover".
Dec 7 '09 #13
gits
5,390 Recognized Expert Moderator Expert
in case it would be essential then have a look here and see if it helps ... but for your specific purpose personally i just would apply another style to the app's background-color or something more visible as a cursor ...

kind regards

PS: ahh ... try acoder's hint first ... may be it helps? ... as i said before ... i never used custom cursors before :)
Dec 7 '09 #14
DMsy2
15 New Member
Is .cur a proprietary M$ format that only IE supports?
Dec 8 '09 #15
rnd me
427 Recognized Expert Contributor
@DMsy2
yes and no.

.cur is basically a monochrome bitmap, so it may be viewable when loaded as a bmp, which many browsers handle.
Firefox allows .cur since 2.0

according to MDC, this is your best bet:
Expand|Select|Wrap|Line Numbers
  1. cursor:  url(foo.cur), url(http://www.example.com/bar.gif), auto;
Dec 13 '09 #16
KeredDrahcir
426 Contributor
Thanks for all your help, acoder's solution of adding the defualt afterwards works. Adding the url(***.cur) stopped working in IE but when I added the default it worked again in IE and now works in Firefox.

Many thanks all,
Dec 14 '09 #17
KeredDrahcir
426 Contributor
I now have it working in IE, Firefox, Safari and Google Chrome. Any ideas how to get it working in Opera?
Dec 15 '09 #18
acoder
16,027 Recognized Expert Moderator MVP
I don't think Opera supports custom cursors.
Dec 21 '09 #19
I also have a similar problem but it's work for me when i entered the full path to the cursor file.
Nov 20 '10 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

3
6888
by: Simon Wigzell | last post by:
I have an image with several links in it in mapped areas. I am using a custom cursor on the page and would like to have a custom cursor appear on mouse over of the mapped links. Something like: ...
4
2517
by: VK | last post by:
I have this code failing to work in IE: getElementsByTagName doesn't return elements from my JS namespace. What's wrong? <html xmlns:js> <head> <title>Que</title> <meta...
1
4556
by: piccolo | last post by:
This is the first time I've posted a 'help' request, so please be patient. I've created a DOM web page where with the usage of usemap images on the page change upon rollover using JavaScript....
1
4587
by: Andy Baxter | last post by:
hello, I'm writing a panoramic image viewer in javascript. When the mouse is over the image, I want it to be a crosshair (over most of the image), or a hand/pointer (when it's over an image map...
3
6443
by: mrsd2c | last post by:
I am building custom attributes as a means to pass data from the client to the server. To accomplish this task, a class of "postback" is applied to a link or button. When the link or button is...
1
2114
by: mshankar | last post by:
hi, friends any one know the solution for how to set the image to a cursor in firefox using javascript i know to set this by using stylesheet cursor :url("ravishankar.cur"),pointer but using...
1
8652
by: ryezack | last post by:
i have an image map with an onmouseover event thats calls a javascript function style cursor is hand. this works in IE but not in firefox. here's the code: <script type="text/javascript"> <!--...
3
4580
by: Klaus Brune | last post by:
Hello all, When one tabs through a form (specifically, in Firefox), all the text in a field is automatically selected. What I'm looking for is a way to put a function (in onFocus perhaps)...
26
2498
by: Prisoner at War | last post by:
Hello, Everyone: Is there any other values or whatever-it's-called to the cursor property in CSS?? So far, I only know of cursor:pointer (or, for MSIE, cursor:hand).... Any way to load in...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7118
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5625
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5049
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.