About us Privacy Disclaimer Contact us
FAQ Help Advertising Feedback
Home Sitemap Search Donate us

  Home > Computer & I'net > Rollovers / Image Swap...

   Browse by title articles:
   What is hot:

Prompt

Status Bar

TimeOut

Location

Windows

Rollovers / Image Swap

NoScript
Photoshop & Web Design Basic FAQ
Now you see it ...
Search Engine Strategies: Selecting Your Key (Words) for Success
Prev articles123 4 5Next articles



Rollovers / Image Swap


Computer & I'net articlesRollovers / Image Swap

by David Stanley    



Rollovers, Mouseovers, Image Swaps... It goes by many variations of names, but means the same thing. Making one image change into a different one when a mouse pointer goes over a specified area.

The first thing you will need are 2 images. One for normal view, a second for the change.

The first image will be placed on the page as it normally would. The one main difference is you have to specify a name in the img tag like so...

<img src="image1.gif" name="MyImage">

This image can now be accessed by javascript as document.MyImage. Of course add in the width, height, alt, and border properties as desired too.

The next part is to create a link around that image. This will allow javascript to affect the image properties.

<a href="" onMouseOver="document.MyImage.src='image2.gif';" onMouseOut="document.MyImage.src='image1.gif';">
<img src="image1.gif" name="MyImage">

</a>

SRC is the SouRCe of the image file.

document.MyImage.src specifies that something is happening to the src of the object named MyImage on this document (web page). Remember... JavaScript is a step language. It goes level by level to find and use something.

OnMouseOver and OnMouseOut are self explanitory. They will do this specified coding when this event happens. For the example, They are being used to specify a new src for the named image.

This type of rollover effect is very common for navigation uses. You can create two images being close to the same. One image may have regular text on it, the other having highlighted text. Put them together in a rollover effect and you have a neat navigation happening. Placing a value in the href will complete the navigation effect.

TROUBLE SHOOTING :
If you have more than one rollover on the same web page, you MUST use a different name value for each one. Using the same name value for two or more will confuse the browser and no effect will be seen.

TIPS :
Try to use two images of the same dimensions for best results.




-----------------
Article by David Stanley. Visit his site http://www.htmlite.com. Reprinted with permission.




Articles

Auto & Trucks

Business

Computer & I'net

  ·General

  ·Apache

  ·CSS

  ·Database

  ·Hardware

  ·HTML

Javascript&DHTML

  ·Linux

  ·MySQL

  ·Operating System

  ·Perl / CGI

  ·PHP

  ·Programming

  ·Publishing

  ·Search Engines

  ·Software Problems

  ·SSI

  ·Tips & Tricks

  ·Utilities

  ·Web Design

Family

Food & Drink

Gardening

Health

Other

Pets

Psychology

Spiritual

Travel

Women

 Calculators

Net Worth




  Disclaimer | Privacy | Terms of useCopyright © 2004 Nice2know.com