faqts : Computers : Programming : Languages : JavaScript : Images

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

43 of 66 people (65%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

JavaScript: Mouse: Cursor: How to change cursor shape when moving over e.g. a picture [hand]

Apr 8th, 2006 17:27
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 09 April 2021 - 00:22 am ----------------------
JavaScript: Mouse: Cursor: How to change cursor shape when moving over 
e.g. a picture [hand]
---
Set e.g. the attribute
 style.cursor
of the current object (which is named 'this')
to the desired shape the mouse cursor.
===
Steps: Overview:
 1. -Create e.g. the following program
--- cut here: begin --------------------------------------------------
<!-------------------------------------------------------------------->
<HTML>
<!-------------------------------------------------------------------->
<IMG
  SRC="c:\\bbc\\taal\\fotoknud.jpg"
  ONMOUSEOVER="this.style.cursor='hand';"
  ONCLICK="alert( 'hello' );"
>
<!-------------------------------------------------------------------->
</HTML>
<!-------------------------------------------------------------------->
--- cut here: end ----------------------------------------------------
 2. -Save this program e.g. as
      myFilename.htm
 3. -Here
     1. -SRC gives the (e.g. full) path to your picture
         (note: use \\ or / to separate, because
                JavaScript wants this)
     2. -ONMOUSEOVER event tells when moving the mouse over the
         picture, it should do something.
         In this case change the mouse cursor shape to a 'hand'
     3. -ONCLICK event tells when you click with your mouse on that
         object (here a picture), it should do something.
         In this case change the mouse cursor shape to a 'hand'
  4. -If you run this file in your browser, when you move
      your mouse cursor over the picture, it will change
      in a hand. When you click on the picture, it will
      show a message 'Hello'.
===
Internet: see also:
---
Custom CSS Cursors
http://www.javascriptkit.com/dhtmltutors/csscursors.shtml
----------------------------------------------------------------------