View Full Version : hi again, another EASY quessie
Gwil Da Skank Of TA
24-05-2000, 18:28
Right, what do i add to the image tag to make it change on mouseover?
Mr_Drinky
25-05-2000, 18:07
Bung this in the head of your html doc.
<BLOCKQUOTE><font size="1" face="Verdana">code:</font><HR><pre>
<script language="javascript">
<!--
// Drinky's scaleable rollover code.
var d = document;
d.oldImage = '';
function swapImage(targetImage, newSrc){
if (d.images){
d.oldImage = targetImage.src;
targetImage.src = newSrc;
}
}
function restoreImage(targetImage){
if(!d.oldImage == ''){
targetImage.src = d.oldImage;
}
}
//-->
</script>
[/code]
use this for your image tags.
<BLOCKQUOTE><font size="1" face="Verdana">code:</font><HR><pre>
<img src="myImage.gif" OnMouseover="javascript:swapImage(this,'newImage.gif');" OnMouseout="javascript:restoreImage(this);">
[/code]
If i havent made any silly errors then it should work (i'm just remembering somethigni wrote a while back). I'll come back and edit this post if i find i've been silly :)
------------------
----------------
James
[This message has been edited by Mr_Drinky (edited 25-05-2000).]
Banana Man
25-05-2000, 19:57
youll want to preload the images tho as well,
just pop this in just after the <!--
<BLOCKQUOTE><font size="1" face="Verdana">code:</font><HR><pre>function MM_preloadImages() { //v2.0
if (document.images) {
var imgFiles = MM_preloadImages.arguments;
if (document.preloadArray==null) document.preloadArray = new Array();
var i = document.preloadArray.length;
with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
preloadArray[i] = new Image;
preloadArray[i++].src = imgFiles[j];
} }
}
MM_preloadImages('image1.GIF','#1')
MM_preloadImages('image2.gif','#2')
MM_preloadImages('image3.gif','#3')
etc.. etc...
[/code]
(there probably an easier way tho)
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.