Forum Moderators: open

Message Too Old, No Replies

Can someone tell me what's wrong with this page?

         

makzan

11:25 am on Jul 14, 2005 (gmt 0)

10+ Year Member



I'm trying to get "email.jpg" to change to "emailorange.jpg" on mouseover.
Can anyone tell me why it's not working and come up with a solution?
Thanks:

===================================

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<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_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_nbGroup(event, grpName) { //v3.0
var i,img,nbArr,args=MM_nbGroup.arguments;
if (event == "init" && args.length > 2) {
if ((img = MM_findObj(args[2]))!= null &&!img.MM_init) {
img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
nbArr[nbArr.length] = img;
for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i]))!= null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = args[i+1];
nbArr[nbArr.length] = img;
} }
} else if (event == "over") {
document.MM_nbOver = nbArr = new Array();
for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i]))!= null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = (img.MM_dn && args[i+2])? args[i+2] : args[i+1];
nbArr[nbArr.length] = img;
}
} else if (event == "out" ) {
for (i=0; i < document.MM_nbOver.length; i++) {
img = document.MM_nbOver[i]; img.src = (img.MM_dn)? img.MM_dn : img.MM_up; }
} else if (event == "down") {
if ((nbArr = document[grpName])!= null)
for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
document[grpName] = nbArr = new Array();
for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i]))!= null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = args[i+1];
nbArr[nbArr.length] = img;
} }
}

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_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>

</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"

onLoad="MM_preloadImages('images/topbar.jpeg','images/greybar.jpg','images/logo_main.bmp','address.jpg','emailorange.jpg','im

ages/email.jpg')">
<div align="left"><img src="images/topbar.jpeg" width="1024"><br><img src="images/greybar.jpg" width="1024"></div>

<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="left" width="176" class="normal" valign="top">
<div style="margin-top: 2px"><img src="images/logo_main.bmp" width="175"></div></td>
<td align="right" width="848" class="normal" valign="top"><div align="right" style="margin-top: 2px"><a href="contact.html"

target="Main"><img src="images/address.jpg" border="0"></a></div>

<div align="right" style="margin-top: 2px"><a href="contact.html" onMouseOut="MM_nbGroup('out');"

onMouseOver="MM_nbGroup('over','emailorange','images/emailorange.jpg','images/emailorange.jpg',1);"

onClick="MM_nbGroup('down','navbar1','emailorange','images/email.jpg',1);MM_swapImage('Nav_r02_c01','','left_nav_main/Nav_r02

_c01.gif','ukmap','','images/ukmap.jpg',1);" target="Main">
<img src="images/email.jpg" border="0"></a></div></td>
<td width="10">&nbsp&nbsp</td>
</tr>
</table>
</body>
</html>

ChadSEO

3:10 pm on Jul 14, 2005 (gmt 0)

10+ Year Member



The only thing that jumps out at me is, in the body onLoad function, you specify 'emailorange.jpg' instead of 'images/emailorange.jpg'

rocknbil

4:52 pm on Jul 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Look at all the MM code! Woo! :-)

You can eliminate most of it with just this:

<a href="contact.html" onMouseOut="emaillink.src='images/email.jpg';" onMouseOver="emaillink.src='images/emailorange.jpg';" target="Main">
<img src="images/email.jpg" name="emaillink" id="emaillink" border="0"></a>

Sorry a bit harried this AM and didn't have time to investigate the onClick, but the idea is: wrtiing your own methods will be far more efficient than the auto-generated MM code.

ChadSEO

4:58 pm on Jul 14, 2005 (gmt 0)

10+ Year Member



I have to agree with rocknbil, writing your own always works better. I don't have much respect for DreamWeaver written HTML, javascript, or stylesheets. It's great for beginners, but any that is serious about web should at least know HOW to write their own, even if they don't all the time.

makzan

8:31 am on Jul 15, 2005 (gmt 0)

10+ Year Member



Thanks very much, but it's still not working!

I haven't worked much with JavaScript and I'm revamping a site, part of which was made with DreamWeaver or some other program. I assume whoever first did it didn't know how to do mouseover (like myself) and so used a program instead.

So, when you said I could replace the code with:

<a href="contact.html" onMouseOut="emaillink.src='images/email.jpg';" onMouseOver="emaillink.src='images/emailorange.jpg';" target="Main">
<img src="images/email.jpg" name="emaillink" id="emaillink" border="0"></a>

exactly which part of the code did you mean?!

Sorry, I will get the hang of js one day!

rocknbil

6:55 pm on Jul 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm trying to get "email.jpg" to change to "emailorange.jpg" on mouseover.

That one line of code (showing as three lines here) should be all that's required to do this.