Below is the basic image preload script for the small round button. Your images will be loaded into the cache & ready to change onMouseOver! Load the following 2 sections between the <HEAD> tags. |
<SCRIPT language="javascript1.1"> if( document.images ) { <!--Small Button--> but1 = new Image(19,19) ; but1.src = "grnon2.gif"; but2 = new Image(19,19) ; but2.src = "grnoff2.gif"; <!--Add additional sets as needed--> } </SCRIPT> |
This next function deals with various versions of browsers and addresses their properties logically. It is a bit larger than my prior code but this should remain stable with future browser upgrades. You need this code only once, even if you have multiple instances of mousovers. |
<SCRIPT> <!-- function chkVer(imagename,objectsrc) { var n=navigator.appName var v=parseInt(navigator.appVersion) var browsok=((n=="Netscape")&&(v>=3)) var browsok2=((n=="Microsoft Internet Explorer")&&(v>=4)) if ((browsok)||(browsok2)) document.images[imagename].src=eval(objectsrc+".src") } //--> </SCRIPT> |
Here is the code that actually displays the images. Place between the <BODY> tags. The HREF may contain a URL, or any javascript function. Note the inclusion of text. |
<A HREF = "Your_URL_here.htm" onmouseover="chkVer('go1','but1')" onmouseout="chkVer('go1','but2')"> <IMG NAME = "go1" width=19 height=19 border=0 SRC = "grnoff2.gif"> <!---Image swap only? put </A> here...or --> Getcher HOT cuppa JavaScript Here!</A> <!---Text Line--> |
Now we can get a bit more clever. This is the 1st part of the code that allows 3 images to be changed at once! 1st, display the Small Image and the Transparent Button that will be swapped. Note that the NAME assigned to each image is different! (and remember to add any new images in your preload script) Add additional image sets as needed. |
<!--These are the mouseOver & "blind" images. They may be placed anywhere on the page, btw.--> <IMG NAME = "go4" width=19 height=19 border=0 SRC = "grnoff.gif"> <!--These are image spacers--> <IMG NAME = "go5" width=19 height=19 border=0 SRC = "clrspace.gif"><!--This is the "blind" (transparent) gif--> |
ANIMATIONS can be handled using the mouseOver code. Remember to add both images in your preload script. |
Pass over the below RECYCLE image. Feel free to use this on your pages if you wish. (A link to my stuff would be nice! The animation itself is: recyc2.gif). To further insure that the animation recycles you may add a # to the end of the gif. [ "recyc2a.gif#" ] |
For an excellent resource on complex GIF animations,
Go HERE
BACK TO BASICS
If you arrived here via a search engine please click here to open the full site!