Forum Moderators: open

Message Too Old, No Replies

JavaScript Tutorial - set mouse pointer position?

         

webtown06

10:17 pm on Apr 17, 2007 (gmt 0)

10+ Year Member



hello everyone:

hello everyone:

I am learning JavaScript. I created a form and I want the mouse pointer points to the first field(a text filed) on the form when the form first displayed on the browser.

Could someone recommend a good JavaScript online tutorial / or online sources to accomplish this task? I appreciate your help?

I also want to what objects, events handler(s) do I need in order to set mourse pointer to a specific location no the form.

I appreciate your help!

Jeff
4-17-09

penders

10:25 pm on Apr 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm pretty sure you can't manipulate the mouse pointers position from JavaScript! I think it would be most annoying for your users if you did!

Under Windows, you can often set the mouse pointer to move to the default button in a dialog - but that is as far as it goes and very much a user preference.

You can, however, move focus to the first field in an HTML form, so the user doesn't have to click with the mouse to start typing.

In order to move to the first element (

elements[0]
) on the first form (
forms[0]
) on the page when the page loads, you could try...

<body onload="document.forms[0].elements[0].focus()">

This uses the forms array of the document object.

httpwebwitch

2:45 pm on May 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I concur - what you want is a focus() on that form element. that way if the user starts typing right away, they'll be typing into the focused element.

Confirmed: there is no way for Javascript to shove the user's pointer around the screen - the pointer is controlled by the user's mouse; manipulating that would be a highly annoying useability flaw, so browsers don't support it.

you can move elements to be under the pointer, but you can't move the pointer to be over an element.

hope that helps