Move mouse pointer in JavaScript
Solution 1:
I don't know about moving the actual rendered mouse pointer, but could you just set the focus on the element?
document.getElementById('the_text_input_id').focus()
Solution 2:
Please see this question:
Mouse move on element
Besides that, I think you are committing major design mistake by taking control of any of the users input in any way (maybe besides setting the focus of a form element)
Solution 3:
Here is a function that select text in an input
or textarea
:
function textSelect(inp, s, e) {
e = e || s;
if (inp.createTextRange) {
var r = inp.createTextRange();
r.collapse(true);
r.moveEnd('character', e);
r.moveStart('character', s);
r.select();
} else if (inp.setSelectionRange) {
inp.focus();
inp.setSelectionRange(s, e);
}
}
To place the cursor at the 12th position:
textSelect(document.getElementById('theInput'), 12);
To select a portion of the input field:
textSelect(document.getElementById('theInput'), 12, 15);
Solution 4:
It would be a huge [security?] issue if they allowed for something like this.
Imagine: you have a setInterval(function(){moveMouseToTopLeftCorner and alert garbage}, 1)...
The user would have his mouse moved to the top left. And then alert would show up [which could be closed with enter].. upon which an alert would immediately pop up again.
You'd actually have to use your keyboard to open taskmanager and kill the browser >_>
However, it is probably possible with ActiveX [although thats IE only... and dumb]