Mouse in image and out : Mouse Event « Event « JavaScript DHTML

Home
JavaScript DHTML
1.Ajax Layer
2.Data Type
3.Date Time
4.Development
5.Document
6.Dojo toolkit
7.Event
8.Event onMethod
9.Ext JS
10.Form Control
11.GUI Components
12.HTML
13.Javascript Collections
14.Javascript Objects
15.Javascript Properties
16.jQuery
17.Language Basics
18.Mochkit
19.Mootools
20.Node Operation
21.Object Oriented
22.Page Components
23.Rico
24.Scriptaculous
25.Security
26.SmartClient
27.Style Layout
28.Table
29.Utilities
30.Window Browser
31.YUI Library
JavaScript DHTML » Event » Mouse Event 
Mouse in image and out
  
/*
JavaScript Application Cookbook
By Jerry Bradenbaugh

Publisher: O'Reilly 
Series: Cookbooks
ISBN: 1-56592-577-7
*/ 

 
<HTML>
<HEAD>
<TITLE>Mouse in image and out</TITLE>
<SCRIPT LANGUAGE="JavaScript1.1">
<!--
var imgNames = new Array('img');
//-->
</SCRIPT>

<SCRIPT LANUAGE="JavaScript">
// images.js

// Set image variables
var imgPath   = 'images/';
var arrayHandles = new Array('out', 'over');

// Dynamically create image arrays
for (var i = 0; i < arrayHandles.length; i++) {
  eval('va' + arrayHandles[i' = new Array()');
  }

// Preload the images
for (var i = 0; i < imgNames.length; i++) {
  imagePreLoad(imgNames[i], i);
  }


// Define a function to preload the images
function imagePreLoad(imgName, idx) {
  for(var j = 0; j < arrayHandles.length; j++) {
    eval(arrayHandles[j"[" + idx + "] = new Image()");
    eval(arrayHandles[j"[" + idx + "].src = '" + imgPath + imgName + arrayHandles[j".gif'");
    }
  }

// Perform the image rollovers
function imageSwap(imagePrefix, imageIndex, arrayIdx) {
  document[imagePrefix].src = eval(arrayHandles[arrayIdx"[" + imageIndex + "].src");
  }

// This function displays the text passed in the browser status bar
function display(stuff) { window.status = stuff; }
</SCRIPT>

</HEAD>
<BODY BGCOLOR=FFFFEE>
<A HREF="javascript: void(0);" 
     onMouseOver="imageSwap('img', 0, 1); display(''); return true;"
     onMouseOut="imageSwap('img', 0, 0); display('');">
<IMG SRC="http://www.java2s.com/style/logo.png"
     NAME=img
     WIDTH=90
     HEIGHT=50
     BORDER=0></A>

</BODY>
</HTML>

           
         
    
  
Related examples in the same category
1.Catches and manages the mouse's events
2.Mouse and key event (IE)
3.Image Mouse on and out
4.Mouse cross hairs
5.Mouse Drag and Drop
6. Creating a Rollover Effect
7.Codependent Link Tag and the onMouseOver Event
8.Which mouse button was clicked?
9.Which element was clicked
10.Mouse over event
11.Get component From Point (Mouse)
12.Cutting and Pasting under Script Control
13.Using Drag-Related Event Handlers
14. Using onDragEnter and onDragLeave Event Handlers
15.Using onMouseDown and onMouseUp Event Handlers
16.Dragging Elements with onMouseMove
17.Using the toElement and fromElement Properties
18. The onBeforeCopy Event Handler
19.Called from an onmousedown event handler
20.Mousedown event handler of an object within a Layer
21.Cursor Arrival and Departure
22.Use Mouse over action to transfer url location
23.Get mouse position with on mouse move event (IE)
24.Get mouse position in mouse down event (IE)
25.H1 double click events
26.Return boolean value for on click event
27.Register mouse down event(IE)
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.