Mouse in image and out : Image Img « HTML « 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 » HTML » Image Img 




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.Get the file name specified in the href or src property
2.Image dynsrc
3.Low resolution Image src
4.Image Long Description
5.Image width Example
6.Does image download completely
7.Alternative Information Example
8.Image align Example
9.Image 'src' Property
10.'height' Example
11.'readyState' Example
12.'galleryImg' Example
13.Monitors the load process and the display of pictures
14.Image Animation
15.Image array
16.Replace image
17.An animating image
18.Scrolling Image
19.Change the height of an image
20.Change image
21.Change image width
22.Count images in a document
23.Image Event Handling
24.Methods and Properties of the Image Object
25.Testing an Image's align Property
26.A Scripted Image Object and Rotating Images
27.Scripting image.complete
28.Changing Between Still and Motion Images
29.Simple Image Replacement
30.Image Error Finder
31.Image element
32.Image Roller Machine
33.Change image in mouse in and out event
34.Use array to store the image names
35.Img onmouseover and onmouseout actions
36.Change vspace for image
37.Change image src
38.Set image height
39.Set image alt message
40.Change image align
41.Change image title
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.