What is the mouse?

C

Csaba2000

I'm probably just blanking today, but, how can I find
out what type the cursor currently is? Is
document.activeElement.style.cursor the way to go on this?
But that's only for IE, right?

Thanks for any tips on this,
Csaba Gabor from New York
 
L

Lasse Reichstein Nielsen

Csaba2000 said:
I'm probably just blanking today, but, how can I find
out what type the cursor currently is?

It's hard.
Is document.activeElement.style.cursor the way to go on this?

Not the "style" element, but "currentStyle" in IE will give the
current style of the object. "activeElement"
But that's only for IE, right?

Right. Same for "activeElement". The standard-based method should
work in Mozilla and Opera 7.2, so if we combine the two, we get:

function getCurrentStyle(elem,prop) {
if (elem.currentStyle) {
return elem.currentStyle[prop];
} else {
var cstyle = document.defaultView.getComputedStyle(elem,null);
return cstyle[prop];
}
}

If you can then find the element that the mouse points to (probably inside
a mouse event handler), then you can use the above to find the cursor:

var cursor = getCurrentStyle(elem,"cursor");

What you can use it for is another question. Mozilla and IE reported "auto",
while Opera 7.2 said "default". Neither Mozilla nor IE changed their opinion
just because I hoovered over an element with a ":hover{cursor:text}" rule.
They both said "auto" anyway. Opera 7.2 did say "text".

Good luck.
/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,083
Messages
2,570,591
Members
47,212
Latest member
RobynWiley

Latest Threads

Top