Forum Moderators: coopster

Message Too Old, No Replies

Javascript MouseOvers included in PHP

         

Icestorm0141

2:10 am on Sep 16, 2007 (gmt 0)

10+ Year Member



Ok I am trying to make this Javascript mouseOver work in php and I think the php coding I have around it is kinda voiding out the Javascript. Here's the code:

<?php
if($site_include=="aboutus.php"){
echo"<a href=\"index.php?ii=aboutus\"><img src=\"images/aboutus_white_o.jpg\" alt=\"About Us\" name=\"About Us\" width=\"200\" height=\"60\" border=\"0\"></a>";
}
else{
echo"<a href=\"index.php?ii=aboutus\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('About Us','','images/aboutus_white_o.jpg',1)\"><img src=\"images/aboutus_white.jpg\" alt=\"About Us\" width=\"200\" height=\"60\" border=\"0\"></a>";
}
?><br>

The image is supposed to be a darkened image of the link is supposed to be a darked font color when you go to that page and not have a mouseOver. This is the reason for the nesting inside the if statement. When you are not on that page the image is supposed to be a mouseOvered image. The if statement, and the mouseOver both work separately but when you combine them the mouseOver no longer works and I cannot figure out why. The url to this page is <snip>.

If someone could help that would be great.

Oh here are the swaping functions:

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.01
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 && 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<(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];}
}

[edited by: eelixduppy at 2:44 am (utc) on Sep. 16, 2007]
[edit reason] removed url [/edit]

cameraman

7:45 am on Sep 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, Icestorm0141!

I've actually managed to go a fair number of years without ever doing a rollover, but in the else, shouldn't the onmouseover and onmouseout stuff be inside the image element instead of the anchor?