11

How can I change position of the mouse cursor on an element when page loading is over with jQuery?

BarryCap
  • 326
  • 3
  • 11
Chalist
  • 3,160
  • 5
  • 39
  • 68
  • 1
    Hey there, it's not possible from a technical point of view. The cursor is controlled by the operating system, while the javascript runs on a lower level of authority on the browser's javascript engine. – Aero Wang Feb 09 '15 at 19:03
  • I'm voting to close this question as off-topic because it's asking for something that had to be made impossible for security reasons. – Joshua Jul 24 '18 at 03:36
  • @Joshua I diden't know. Tnx anyway. – Chalist Jul 24 '18 at 23:21

5 Answers5

22

This is not possible.

I also disagree with highjacking the users mouse position, even if it were possible. If you did that to me as a user I would immediately leave your site.

JavaScript was designed this way on purpose. Imagine the internet as it is today with all the crappy sites and exploits out there, mix in the ability to control the users mouse and you have a much worse experience.

Let your users decided what they want to click on.

JP Silvashy
  • 46,977
  • 48
  • 149
  • 227
  • In fact, can *any* application move the mouse? Is that something apps are even allowed to do by most OSes? – Matchu Jan 20 '10 at 23:13
  • 1
    Sure, you can hijack the user input on OSX if you want. I think its a miserable idea. Remember Windows had a functionality that would automatically move your mouse cursor to the any dialogs box "ok" button... what a bad idea. – JP Silvashy Jan 20 '10 at 23:19
  • Here check this out! http://www.microsoft.com/windowsxp/using/accessibility/snapto.mspx – JP Silvashy Jan 20 '10 at 23:20
  • 3
    Then again, you could use it in a humorous way. The first program I ever wrote was a bastardized version of pong which would move your paddles the wrong way --just-- as you were about to hit the ball. I loved watching my instructor try to play that. The game would start normally and randomly do this, so it was very deceiving. – Michael Balint Jan 20 '10 at 23:40
  • 2
    I hate popup windows, alert dialogs, confirm dialogs, target=_blank, and a many tons of these things. But, in fact, I don't hate these browser features, I hate the way bad websites use them. When using right, they are pleasures for both developers and users. So, my opinion, provide these features, let users teach developers how to use them right by walking away from their sites just like you do; but remember to provide these features. – deerchao Dec 17 '11 at 13:23
  • for the record, there are non-UI reasons for doing this in the console, especially in the area of writing tests and prototyping. I agree, though, that websites should never do this. – patrickgamer Jun 28 '12 at 17:10
  • 2
    -1: It's true for the general case, and it's probably good that JS doesn't allow it, but that doesn't mean that "religiously" every case is bad. Example: A timeline item that has "<" and ">" button moving the item a little bit left/right as you click it. You'd want to be able to click, click, click to move it but this means your cursor would have to follow the item as it moves. – Wernight Dec 02 '13 at 16:41
  • @Matchu, well, there are programs that automatically move the mouse. – Jacques Marais Nov 26 '15 at 17:18
  • this is not an answer, this is your opinion. – ofir_aghai Sep 20 '18 at 06:19
  • 1
    @ofir_aghai i added a statement on how this is not possible. – JP Silvashy Sep 20 '18 at 11:26
6

I think you can redraw the whole content of your web page so that the element you want get under the cursor. “ψ(`∇´)ψ

Another solution would be to move the window so that it gets where you want “ψ(`∇´)ψ

serenesat
  • 4,611
  • 10
  • 37
  • 53
barjo
  • 69
  • 1
  • 1
  • 1
    Next up, just teleport the physical CRT screen to cause vibrations that move the physical pointer device in such a way to align stuff so it gets where you want! – wallabra Sep 09 '20 at 19:09
2

Javascript isn't able to move the mouse cursor -- it would be annoying as all get out if it could do this.

Kaleb Brasee
  • 51,193
  • 8
  • 108
  • 113
1

If you're wanting to physically move the mouse for the user, this can not be done with Javascript or any other typical web technology.

I'd say I'm sorry, but I'm not. That's one of the worst possible things you could do to a user.

Matchu
  • 83,922
  • 18
  • 153
  • 160
0

Fortunately that's not possible with Javascript or any other typical/common technology. Imagine not having the free will on what you click on.