Monday, 13 October 2008

Javascript to Change the Cursor Style

Changing the cursor with Javascript is pretty easy.

document.body.style.cursor = 'wait';

Changes the cursor to the wait/busy style.

document.body.style.cursor = 'default';

Changes the cursor back to the pointer.

There are several different styles you can use, however if your aiming to be compatable with older browsers you may want to do some testing.

The styles are:
  • auto
  • crosshair
  • default
  • pointer
  • help
  • move
  • text
  • wait

And the resize styles:
  • e-resize
  • w-resize
  • n-resize
  • s-resize
  • ne-resize
  • nw-resize
  • se-resize
  • sw-resize
Cursor Styled.

No comments: