Saturday 4 June 2011

How do I create an image that changes on a mouse over?

I don%26#039;t have a lot of experience. I know how to get image location and stuff though. I want to basically make an image and when you put you%26#039;re mouse over it, it will change to another, and then of course when you take your mouse off, it will change back. I just have basic software that comes with Vista so I%26#039;m assuming I use notepad? I need basic step by step instructions and of course I%26#039;ll pick a best answer.|||Don%26#039;t need that much darn code. This is all CSS.





Between the head tags -





%26lt;style type=%26quot;text/css%26quot;%26gt;


* { margin: 0; padding: 0; border: 0; }





a { display: block; text-decoration: none; }





a:link.mousie {


width: 455px;


height: 132px;


background: url(mouseoff_image.jpg) no-repeat center scroll;


}





a:hover.mousie {


background: url(mouseon_image.jpg) no-repeat center scroll;


}





div#link_container {


width: 455px;


margin: 5% auto;


}





.mousie span {


visibility: hidden;


}


%26lt;/style%26gt;





Between the body tags -





%26lt;div id=%26quot;link_container%26quot;%26gt;





%26lt;a class=%26quot;mousie%26quot; href=%26quot;#URL_Path_Here%26quot; title=%26quot;Mouseover Description%26quot;%26gt;%26lt;span%26gt;Text Link Description hidden%26lt;/span%26gt;%26lt;/a%26gt;





%26lt;/div%26gt;





Ron|||here is some code that will let you do it:





%26lt;head%26gt;


%26lt;meta http-equiv=%26quot;Content-Type%26quot; content=%26quot;text/html; charset=utf-8%26quot; /%26gt;


%26lt;title%26gt;Untitled Document%26lt;/title%26gt;


%26lt;script type=%26quot;text/javascript%26quot;%26gt;


%26lt;!--


function MM_swapImgRestore() { //v3.0


var i,x,a=document.MM_sr; for(i=0;a%26amp;%26amp;i%26lt;a.length%26amp;%26amp;(x=a[i])%26amp;%26amp;x.oSrc;鈥?x.src=x.oSrc;


}


function MM_preloadImages() { //v3.0


var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();


var i,j=d.MM_p.length,a=MM_preloadImages.arg鈥?for(i=0; i%26lt;a.length; i++)


if (a[i].indexOf(%26quot;#%26quot;)!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}


}





function MM_findObj(n, d) { //v4.01


var p,i,x; if(!d) d=document; if((p=n.indexOf(%26quot;?%26quot;))%26gt;0%26amp;%26amp;parent.frames.l鈥?{


d=parent.frames[n.substring(p+1)].docume鈥?n=n.substring(0,p);}


if(!(x=d[n])%26amp;%26amp;d.all) x=d.all[n]; for (i=0;!x%26amp;%26amp;i%26lt;d.forms.length;i++) x=d.forms[i][n];


for(i=0;!x%26amp;%26amp;d.layers%26amp;%26amp;i%26lt;d.layers.length;鈥?x=MM_findObj(n,d.layers[i].document);


if(!x %26amp;%26amp; d.getElementById) x=d.getElementById(n); return x;


}





function MM_swapImage() { //v3.0


var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i%26lt;(a.length-2);i+=3)


if ((x=MM_findObj(a[i]))!=null){document.MM鈥?if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}


}


//--%26gt;


%26lt;/script%26gt;


%26lt;/head%26gt;





%26lt;body onload=%26quot;MM_preloadImages(%26#039;file:///C|/Gfl鈥?br>

%26lt;a href=%26quot;http://www.example.com%26quot; onmouseout=%26quot;MM_swapImgRestore()%26quot; onmouseover=%26quot;MM_swapImage(%26#039;Image1%26#039;,%26#039;%26#039;,%26#039;f鈥?src=%26quot;file:///C|/pic2.JPG%26quot; name=%26quot;Image1%26quot; width=%26quot;566%26quot; height=%26quot;471%26quot; border=%26quot;0%26quot; id=%26quot;Image1%26quot; /%26gt;%26lt;/a%26gt;


%26lt;/body%26gt;


%26lt;/html%26gt;








just take a close look at what is doing what, you should be able to figure it out.





if you still need help, send me a PM or mail or something and ill see what i can do for you.