Click to See Complete Forum and Search --> : active gifs


Lethal
04-13-2001, 11:28 PM
I have seen on some internet web sites active gifs where when you hover over them they will change. like on menus the backround will go from black to white
can someone help me in accomplishing this or lead me to a program that can do this thanks in advance

namgor
04-13-2001, 11:59 PM
To do this in HTML, you need to use Javascript to help you. For example, add this in front of your HTML code, exception to change the filename:

function MM_swapImgRestore() {
if (document.MM_swapImgData != null)
for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_swapImage() {
var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
if ((objStr.indexOf('document.layers[')==0 && document.layers==null) | |
(objStr.indexOf('document.all[') ==0 && document.all ==null))
objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.l ength);
obj = eval(objStr);
if (obj != null) {
swapArray[j++] = obj;
swapArray[j++] = (oldArray==null | | oldArray[j-1]!=obj)?obj.src http://www.sharkyforums.com/ubb/redface.gifldArray[j];
obj.src = MM_swapImage.arguments[i+2];
}
}
document.MM_swapImgData = swapArray;
}

then, in every gif, you simply add

onMouseOver = "scriptname ('new gif.gif');


I know it is confusing above. Check http://javascript.internet.com for an easier example.


------------------
I am crab, scoins is crap.

gammaray51
04-14-2001, 01:32 AM
either that or flash. It boils down to.. flash cost money, java is free.

dighn
04-14-2001, 05:38 PM
It's not Java, it's JavaScript. You can also do it in Java but it's not worth the trouble.

------------------
someone set up us the bomb!

buddylee123
04-14-2001, 06:39 PM
Flash doesn't cost any money, you know what i'm talking about. (inapropriate!=0 )

------------------
I enjoy ham

Milkman
04-14-2001, 08:24 PM
the above image swap code is very good, however here is yet another version:

the preload script in the head section (it preloads each image into the system's cache):

var image1=new Image()
image1.src="yourmousedoverimage.gif"

copy the above for all of the images you wish to preload.

then, you must make each image a link:

<a href="#" onMouseOver="image1.src='yourmousedoverimage.gif'"; onMouseOut="image1.src='yourimage.gif'"; return false><img src="yourimage.gif" name="image1"></a>

Follow this method for all of your images assigning each one a different name...if this is confusing, http://www.webmonkey.com has some great javascript tutorials. The other method posted far above would be a better choice, but again, it is a matter of preference http://www.sharkyforums.com/ubb/smile.gif



------------------
"There are two steps to success: 1. Never tell everything you know 2. See #1"

Lethal
04-15-2001, 12:54 AM
just thought i would say thanks for the help you guys were very helpful