Is it possible to get the mouse position with JavaScript after page loads without any mouse movement event (without moving the mouse)?
+2
A:
Real answer: No, it's not possible.
OK, I have just thought of a way. Overlay your page with a div that covers the whole document. Inside that, create (say) 2,000 x 2,000 <a>
elements (so that the :hover
pseudo-class will work in IE 6, see), each 1 pixel in size. Create a CSS :hover
rule for those <a>
elements that changes a property (let's say font-family
). In your load handler, cycle through each of the 4 million <a>
elements, checking currentStyle
/ getComputedStyle()
until you find the one with the hover font. Extrapolate back from this element to get the co-ordinates within the document.
N.B. DON'T DO THIS.
Tim Down
2010-04-08 15:20:27
ha ha - at some point you should google around and see if you can figure out how many people have actually implemented this
Pointy
2010-04-08 15:46:57
Upvoted, just for the sheer hilarity.
Ryan McGrath
2010-04-08 16:03:53