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 2 Alternate Images
Insert into <HEAD>
<script language="JavaScript"> <!-- Hide from old browsers if (navigator.appVersion.indexOf("2.") != -1){ check = false; } if ((navigator.appVersion.indexOf("3.") != -1) && (navigator.appName.indexOf("Explorer") != -1)){ check = false; } else { check = true; } if (check == true){ image1= new Image(); image1.src = "IMAGE OFF #1"; image1on = new Image(); image1on.src = "IMAGE ON #1"; image1alt1 = new Image(); image1alt1.src = "ALT IMAGE OFF #1a"; image1alton1 = new Image(); image1alton1.src = "ALT IMAGE ON #1a"; image1alt2 = new Image(); image1alt2.src = "ALT IMAGE OFF #1b"; image1alton2 = new Image(); image1alton2.src = "ALT IMAGE ON #1b"; image2= new Image(); image2.src = "IMAGE OFF #2"; image2on = new Image(); image2on.src = "IMAGE ON #2"; image2alt1 = new Image(); image2alt1.src = "ALT IMAGE OFF #2a"; image2alton1 = new Image(); image2alton1.src = "ALT IMAGE ON #2a"; image2alt2 = new Image(); image2alt2.src = "ALT IMAGE OFF #2b"; image2alton2 = new Image(); image2alton2.src = "ALT IMAGE ON #2b"; } function imageon(name) { document[name].src = eval(name + "on.src"); document[name + "alt1"].src = eval(name + "alton1.src"); document[name + "alt2"].src = eval(name + "alton2.src"); } function imageoff(name) { document[name].src = eval(name + ".src"); document[name + "alt1"].src = eval(name + "alt1.src"); document[name + "alt2"].src = eval(name + "alt2.src"); } NN3 = true; function on(name) { if (check == true){ imageon(name); } } function off(name) { if (check == true){ imageoff(name); } } // --> </script>
Insert into <BODY>
Linked Changing Image #1 <a href="YOUR LINK" onmouseover="on('image1');" onmouseout="off('image1')"><img src="IMAGE OFF #1" border="0" name="image1"></a> First Alternate Image #1 <img src="ALT IMAGE OFF #1a" name="image1alt1"> Second Alternate Image #1 <img src="ALT IMAGE OFF #1b" name="image1alt2"> Linked Changing Image #2 <a href="YOUR LINK" onmouseover="on('image2');" onmouseout="off('image2')"><img src="IMAGE OFF #2" border="0" name="image2"></a> First Alternate Image #2 <img src="ALT IMAGE OFF #2a" name="image2alt1"> Second Alternate Image #2 <img src="ALT IMAGE OFF #2b" name="image2alt2">
Other Options
First thing to do is to put this in your <head></head> tag. Change these variables: IMAGE OFF, IMAGE ON, ALT IMAGE OFF #a, ALT IMAGE ON #a, ALT IMAGE OFF #b, and ALT IMAGE ON #b. (Yes it's a lot of work!) <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 if (navigator.appVersion.indexOf("2.") != -1){ check = false; } if ((navigator.appVersion.indexOf("3.") != -1) && (navigator.appName.indexOf("Explorer") != -1)){ check = false; } else { check = true; } if (check == true){ image1= new Image(); image1.src = "IMAGE OFF #1"; image1on = new Image(); image1on.src = "IMAGE ON #1"; image1alt1 = new Image(); image1alt1.src = "ALT IMAGE OFF #1a"; image1alton1 = new Image(); image1alton1.src = "ALT IMAGE ON #1a"; image1alt2 = new Image(); image1alt2.src = "ALT IMAGE OFF #1b"; image1alton2 = new Image(); image1alton2.src = "ALT IMAGE ON #1b"; image2= new Image(); image2.src = "IMAGE OFF #2"; image2on = new Image(); image2on.src = "IMAGE ON #2"; image2alt1 = new Image(); image2alt1.src = "ALT IMAGE OFF #2a"; image2alton1 = new Image(); image2alton1.src = "ALT IMAGE ON #2a"; image2alt2 = new Image(); image2alt2.src = "ALT IMAGE OFF #2b"; image2alton2 = new Image(); image2alton2.src = "ALT IMAGE ON #2b"; } function imageon(name) { document[name].src = eval(name + "on.src"); document[name + "alt1"].src = eval(name + "alton1.src"); document[name + "alt2"].src = eval(name + "alton2.src"); } function imageoff(name) { document[name].src = eval(name + ".src"); document[name + "alt1"].src = eval(name + "alt1.src"); document[name + "alt2"].src = eval(name + "alt2.src"); } NN3 = true; function on(name) { if (check == true){ imageon(name); } } function off(name) { if (check == true){ imageoff(name); } } // --> </script> Now here are all the images. You need to change YOUR LINK, IMAGE OFF #, ALT IMAGE OFF #a, and ALT IMAGE OFF #b Linked Changing Image #1 <a href="YOUR LINK" onmouseover="on('image1');" onmouseout="off('image1')"><img src="IMAGE OFF #1" border="0" name="image1"></a> First Alternate Image #1 <img src="ALT IMAGE OFF #1a" name="image1alt1"> Second Alternate Image #1 <img src="ALT IMAGE OFF #1b" name="image1alt2"> Linked Changing Image #2 <a href="YOUR LINK" onmouseover="on('image2');" onmouseout="off('image2')"><img src="IMAGE OFF #2" border="0" name="image2"></a> First Alternate Image #2 <img src="ALT IMAGE OFF #2a" name="image2alt1"> Second Alternate Image #2 <img src="ALT IMAGE OFF #2b" name="image2alt2"> -------------------------------------------------------------------------------- Here is an example of adding a third set of images. Adjust the top script by adding these additional lines. This goes after the lines that look identical. image3= new Image(); image3.src = "IMAGE OFF #3"; image3on = new Image(); image3on.src = "IMAGE ON #3"; image3alt1 = new Image(); image3alt1.src = "ALT IMAGE OFF #3a"; image3alton1 = new Image(); image3alton1.src = "ALT IMAGE ON #3a"; image3alt2 = new Image(); image3alt2.src = "ALT IMAGE OFF #3b"; image3alton2 = new Image(); image3alton2.src = "ALT IMAGE ON #3b"; Notice how "image2" went to "image3" and "image2alt1" went to "image3alt1" and so on. To add a fourth image you would replace all the "image3"'s with "image4". 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 OFF #3" border="0" name="image3"></a> First Alternate Image #3 <img src="ALT IMAGE OFF #3a" name="image3alt1"> Second Alternate Image #3 <img src="ALT IMAGE OFF #3b" name="image3alt2"> 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".