ramon22 Posted August 30, 2006 Share Posted August 30, 2006 hi am having trouble making the buttons change when the mouse is over themhere is the code <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <script language="JavaScript"><!--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.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}function MM_findObj(n, d) { //v4.0 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && document.getElementById) x=document.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<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}//--></script> </head> <body onload="MM_preloadImages('images/m1_r.jpg','images/m2_r.jpg','images/m3_r.jpg','images/m4_r.jpg','images/m5_r.jpg')" bgcolor="#DEAD08" leftmargin="50" marginheight="0" marginwidth="50" topmargin="0"> <table width="636" border="0" cellspacing="0" cellpadding="0" align="center" height="277"> <tr height="100%"> <td colspan="3" valign="top" height="100%"><img src="images/logo.jpg" alt="" height="136" width="636" border="0"/></td> </tr> <tr height="40"> <td colspan="3" height="40"><img src="images/m0.jpg" alt="" height="40" width="202" border="0"/><a onmouseover="MM_swapImage('Image1','','images/m1_r.jpg',1)" onmouseout="MM_swapImgRestore()" href="java script:;"><img src="images/m1.jpg" alt="" height="40" width="87" border="0"/></a><a onmouseover="MM_swapImage('Image2','','images/m2_r.jpg',1)" onmouseout="MM_swapImgRestore()" href="java script:;"><img src="images/m2.jpg" alt="" height="40" width="87" border="0"/></a><a onmouseover="MM_swapImage('Image3','','images/m3_r.jpg',1)" onmouseout="MM_swapImgRestore()" href="java script:;"><img src="images/m3.jpg" alt="" height="40" width="87" border="0"/></a><a onmouseover="MM_swapImage('Image4','','images/m4_r.jpg',1)" onmouseout="MM_swapImgRestore()" href="java script:;"><img src="images/m4.jpg" alt="" height="40" width="87" border="0"/></a><a onmouseover="MM_swapImage('Image5','','images/m5_r.jpg',1)" onmouseout="MM_swapImgRestore()" href="java script:;"><img src="images/m5.jpg" alt="" height="40" width="85" border="0"/></a></td> </tr> <tr> <td colspan="3"><img src="images/background.jpg" alt="" height="101" width="635" border="0"/></td> </tr> </table> <p></p> </body></html> thank you for all the help Link to comment Share on other sites More sharing options...
reportingsjr Posted August 30, 2006 Share Posted August 30, 2006 wow... you have.. way too much code!!! try this: <button onmouseover="this.innerHTML = 'Changed now!'" onmouseout="this.innerHTML = 'Change this!'">Change this!</button> That would change back and forth from "Change this!" to "Changed now!".If you want it to change like a background picture replace .innerHTML with .style.background-image = 'url("urlofimage")' Link to comment Share on other sites More sharing options...
ramon22 Posted August 31, 2006 Author Share Posted August 31, 2006 wow... you have.. way too much code!!! try this:<button onmouseover="this.innerHTML = 'Changed now!'" onmouseout="this.innerHTML = 'Change this!'">Change this!</button> That would change back and forth from "Change this!" to "Changed now!".If you want it to change like a background picture replace .innerHTML with .style.background-image = 'url("urlofimage")' no man not a buttton its an image of a button that i want it to animate when the mouse is over the picture Link to comment Share on other sites More sharing options...
aspnetguy Posted August 31, 2006 Share Posted August 31, 2006 var orig = true;function swap(obj,img1,img2){ orig = !orig; if(orig) obj.src = img1; else obj.src = img2;}......<img src="img1.gif" alt="" onmouseover="swap(this,'img1.gif','img2.gif')" onmouseout="swap(this,'img1.gif','img2.gif')"/> try something like that. Did you really need preloading of images? Link to comment Share on other sites More sharing options...
ramon22 Posted September 1, 2006 Author Share Posted September 1, 2006 thank you it worked ,am a noob in javaScript thought i needed the preloading of images Link to comment Share on other sites More sharing options...
Chocolate570 Posted September 1, 2006 Share Posted September 1, 2006 Where does everyone get that preloading script from? It seems to be the only one used! :S Link to comment Share on other sites More sharing options...
aspnetguy Posted September 1, 2006 Share Posted September 1, 2006 I think it is from Photoshop. Link to comment Share on other sites More sharing options...
kansasprog Posted September 1, 2006 Share Posted September 1, 2006 I think it is from Photoshop.Nope.Its from Macromedia Fireworks i guess. all functions starting with MM are from macromedia. Link to comment Share on other sites More sharing options...
Chocolate570 Posted September 1, 2006 Share Posted September 1, 2006 Well, it's so complex for no reason. I can't see anything it can do that my 6 line script couldn't do. Besides the staying on my hard drive thing. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now