Metachecker.net
|
FontsMadeEasy.com
|
RankChecker.net
Learn Java Script Today
|
Over 5000 Free Fonts
|
Tutorials
|
Javascript Forum
|
Other Javascript Resources
|
Cheat Sheet
JavaScript Basics
Inserting Javascript
Complete Tutorial
Advance DHTML Tutorial
Script archive
Advanced Tutorials
Alert Scripts
Animation
Audio
Background Effects
Banner Ads
Browser Window
Buttons
Button Forms
Calculcators
Calendars
Clocks & Dates
Cookies
Cursor Effects
DHMTL Games
DHTML Miscellaneous
Equivalents
Forms
Games
IE4+ Scripts
IE5+ Scripts
Image Effects
Image Miscellaneous
Links & Buttons
Math Related
Messages Miscellaneous
Miscellaneous
Mouse Tricks
Navigation
Page Details
Password Protection
Pulldown Menus
Random Stuff
Scrolling
Status Bar
Text Animation
User Detail
User Info
Window Control
Changing Image And Alternate Image
Insert into <HEAD>
<script language="JavaScript"> <!-- Hide from old browsers var NN3 = false; image1= new Image(); image1.src = "IMAGE OFF"; image1on = new Image(); image1on.src = "IMAGE ON"; image1alt = new Image(); image1alt.src = "ALT IMAGE OFF"; image1alton = new Image(); image1alton.src = "ALT IMAGE ON"; image2= new Image(); image2.src = "IMAGE OFF"; image2on = new Image(); image2on.src = "IMAGE ON"; image2alt = new Image(); image2alt.src = "ALT IMAGE OFF"; image2alton = new Image(); image2alton.src = "ALT IMAGE ON"; function on3(name) { document[name].src = eval(name + "on.src"); document[name + "alt"].src = eval(name + "alton.src"); } function off3(name) { document[name].src = eval(name + ".src"); document[name + "alt"].src = eval(name + "alt.src"); } NN3 = true; function on(name) { if (NN3) on3(name); } function off(name) { if (NN3) off3(name); } // --> </script>
Insert into <BODY>
Linked Changing Image #1: <a href="YOUR LINK" onmouseover="on('image1');" onmouseout="off('image1')"><img src="IMAGE OFF" border="0" name="image1"></a> Alternate Image #1 <img src="ALT IMAGE OFF" name="image1alt"> Linked Changing Image #2: <a href="YOUR LINK" onmouseover="on('image2');" onmouseout="off('image2')"><img src="IMAGE OFF" border="0" name="image2"></a> Alternate Image #2 <img src="ALT IMAGE OFF" name="image2alt">
Other Options
First thing to do is to put this in your <head></head> tag. You will need to edit IMAGE OFF, IMAGE ON, ALT IMAGE ON, and ALT IMAGE OFF. (ALT IMAGE ON and OFF are your alternate images, for example, mine are the numbers.) <script language="JavaScript"> <!-- Hide from old browsers // Copyright © 1999 Doug Popeney // Created by Doug Popeney (easyjava@easyjavascipt.com) // JavaScript Made Easy!! - http://www.easyjavascript.com var NN3 = false; image1= new Image(); image1.src = "IMAGE OFF"; image1on = new Image(); image1on.src = "IMAGE ON"; image1alt = new Image(); image1alt.src = "ALT IMAGE OFF"; image1alton = new Image(); image1alton.src = "ALT IMAGE ON"; image2= new Image(); image2.src = "IMAGE OFF"; image2on = new Image(); image2on.src = "IMAGE ON"; image2alt = new Image(); image2alt.src = "ALT IMAGE OFF"; image2alton = new Image(); image2alton.src = "ALT IMAGE ON"; function on3(name) { document[name].src = eval(name + "on.src"); document[name + "alt"].src = eval(name + "alton.src"); } function off3(name) { document[name].src = eval(name + ".src"); document[name + "alt"].src = eval(name + "alt.src"); } NN3 = true; function on(name) { if (NN3) on3(name); } function off(name) { if (NN3) off3(name); } // --> </script> Now put these lines anywhere in you HTML document Linked Changing Image #1: <a href="YOUR LINK" onmouseover="on('image1');" onmouseout="off('image1')"><img src="IMAGE OFF" border="0" name="image1"></a> Alternate Image #1 <img src="ALT IMAGE OFF" name="image1alt"> Linked Changing Image #2: <a href="YOUR LINK" onmouseover="on('image2');" onmouseout="off('image2')"><img src="IMAGE OFF" border="0" name="image2"></a> Alternate Image #2 <img src="ALT IMAGE OFF" name="image2alt"> Now change YOUR LINK, IMAGE OFF, and ALT IMAGE OFF. Now if you want add more images, you'll have to adjust the top script by adding this additional line. (this is an example of how to add a third image image)This goes after the lines that look identical. image3= new Image(); image3.src = "IMAGE FILE OFF"; image3on = new Image(); image3on.src = "IMAGE FILE ON"; image3alt = new Image(); image3alt.src = "ALT IMAGE OFF"; image3alton = new Image(); image3alton.src = "ALT IMAGE ON"; Notice how "image2" went to "image3" and "image2alt" went to "image3alt". To add a fourth image you would replace all the "image3"'s with "image4" and so on. Now put this link in the body of your document to make the third image visible. Linked Changing Image #3 <a href="YOUR LINK" onmouseover="on('image3');" onmouseout="off('image3')"><img src="IMAGE FILE OFF" border="0" name="image3"></a> Alternate Image #3 <img src="ALT IMAGE OFF" name="image3alt"> Notice how the image number went up to "image3". Repet all the steps that I just showed you to put in a fourth or fifth image and change "image3" to "image4" or "image5". Same goes for "image3alt".