iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (34)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

May 16, 2008
Who Are Your Top Friends on Facebook?
About
 
May 15, 2008
Reader Question - Would you host your client's work on your website?
About
 
May 15, 2008
How to Create an Ajax Autocomplete Text Field: Part 6
WebReference.com
 
May 14, 2008
Poll: Are the browser safe colors still needed?
About
 
May 14, 2008
Google Doctype launched
About
 
May 14, 2008
Web Editor Reviews - 6 New Reviews
About
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /JavaScript

Rollover images 

  Views:    4916
  Votes:    3
by Diego Botello 12/10/03 Rating: 

Synopsis:

This article talks about the way of making rollover images.
Pages: 
The Article

Rollover images are a very useful effect on webpages. They make easier for you to point out site features to your users. First you need to have the images that you want to use. On this example we are going to use the following images. As you can see, commonly we use two images of the same size, although this is not necessary.

The following example illustrates the use of rollover images.

<html>
<head>
<script>
<!-- function rollover(image) {

document.image1.src=image;
}

// -->
</script>
</head>
<body>

<img src="roll1.gif"
alt="Move your mouse over here!" name="image1" OnMouseOver="rollover('roll2.gif')"
OnMouseOut="rollover('roll1.gif')">

</body>
</html>

Lets discuss the code above. The function rollover is the one that makes the job of changing the image. It accepts a parameter (image) which contains the source of the image to show. document.image1.src establishes the source of the image.

function rollover(image) {
document.image1.src=image;
}
 

On the img tag we have placed two events, OnMouseOver and OnMouseOut which calls the rollover function. roll2.gif and roll1.gif are the sources of our images. Notice that we have to call both events because if we only call OnMouseOver then the image will not return to its original state after the mouse leaves.

Pages: 



 
  Sponsors