Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Cursor Manipulation

How do I change my mouse pointer with JavaScript? by Einstein47
Posted: 7 Mar 03

Your mouse pointer (cursor) is just another element on a web page. You can control many aspects of how it looks in response to different events on your web page.

Let's say you have a form that takes a few seconds to process and you want to let your users know not to keep clicking the "submit" button. You can very simply add the following to the <FORM> HTML tag:

<FORM ... onsubmit="document.body.style.cursor='wait'">

Be aware that this will not work on older versions of browsers - your mileage may vary, see dealer for details. But the nice thing is that with a single line you can tell your users that something is happening.

Here is a list of possible cursors you can use:

  • auto

  • crosshair

  • default

  • pointer (hand in IE 5.x)

  • help

  • move

  • text

  • wait

  • e-resize, w-resize, n-resize, s-resize, ne-resize, nw-resize, se-resize, sw-resize

These values can be assigned with the onmouseover / onmouseout event handlers for any image or page element. For example add this to an image on your page:

<IMG src=".." ... onmouseover="this.style.cursor='crosshair';">

Hopefully you can experiment with cursor control and let it be another extension of your web pages.

Back to Javascript FAQ Index
Back to Javascript Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close