PDA

View Full Version : MR J - Help with some of your code



Indiana
Aug 7th, 2007, 09:33 PM
I found some code that really helped me out:

<script language="JavaScript">
<!--
var Images = new Array("our_team_off2.gif","our_team_on.gif","projects_off.gif","projects_on.gif","links_off.gif","links_on.gif","six_sigma_off.gif","six_sigma_on.gif","contact_us_off1.gif","contact_us_on.gif","about_us_off1.gif","about_us_on.gif") // list images to preload
var preloadImages=new Array() // preloads images
for (i=0;i<=Images.length-1;i++) {
preloadImages[i]=new Image()
preloadImages[i].src=Images[i]
}

LastID = ""

function ON(id,picon){
(LastID != id?document.getElementById(id).src = picon:"")
}

function OFF(id,picoff){
(LastID != id?document.getElementById(id).src = picoff:"")
}

Lastpic=""
function active(id,picon,picoff){
document.getElementById(id).src = picon
if (LastID != ""){
(LastID != id?document.getElementById(LastID).src = Lastpic:"")
}
LastID = id
Lastpic=picoff
}
// -->
</script>

</HEAD>
<BODY>
<a href="#null" onclick="active('mypic1','our_team_on.gif','our_team_off2.gif');this.blur()" onmouseover="ON('mypic1','our_team_on.gif' )" onmouseout="OFF('mypic1','our_team_off2.gif')"><img src="our_team_off2.gif" border="0" name="mypic1" ALT= "Your Choice"></a> <BR>

<a href="#null" onclick="active('mypic2','projects_on.gif','projects_off.gif');this.blur()" onmouseover="ON('mypic2','projects_on.gif' )" onmouseout="OFF('mypic2','projects_off.gif')"><img src="projects_off.gif" border="0" name="mypic2" ALT= "Your Choice"></a><BR>

<a href="#null" onclick="active('mypic3','links_off_on.gif','links_off.gif');this.blur()" onmouseover="ON('mypic3','links_off.gif' )" onmouseout="OFF('mypic3','links_off.gif')"><img src="links_off.gif" border="0" name="mypic3" ALT= "Your Choice"></a><BR>

<a href="#null" onclick="active('mypic4','six_sigma_on.gif','six_sigma_off.gif');this.blur()" onmouseover="ON('mypic4','six_sigma_on.gif' )" onmouseout="OFF('mypic4','six_sigma_off.gif')"><img src="six_sigma_off.gif" border="0" name="mypic4" ALT= "Your Choice"></a><BR>

<a href="#null" onclick="active('mypic5','contact_us_on.gif','contact_us_off.gif');this.blur()" onmouseover="ON('mypic5','contact_us_on.gif' )" onmouseout="OFF('mypic5','contact_us_off.gif')"><img src="contact_us_off.gif" border="0" name="mypic5" ALT= "Your Choice"></a><BR>

<a href="#null" onclick="active('mypic6','about_us_on.gif','about_us_off1.gif');this.blur()" onmouseover="ON('mypic6','about_us_on.gif' )" onmouseout="OFF('mypic6','about_us_off1.gif')"><img src="about_us_off1.gif" border="0" name="mypic6" ALT= "Your Choice"></a>

I was beating my head against the wall trying to get my menu to work right and had tried multiple codes. Yours was the first that my newbie brain understood enough to get to work.

2 Follow-up questions:

1. My, "Home" button I have, "on" when the page loads. What code can I add to get that to turn "off" when the user selects another button?

2. Can you explain your code. My newbie brain understands some of it. But other parts are a mystery.

Indiana
Aug 7th, 2007, 10:21 PM
I should say how can I get the "HOME" button to stay on while on the "HOME" page. It currently turns off as soon as a mouseover event takes place.

Nischumacher
Aug 8th, 2007, 10:21 AM
PaRDoN Me... BuT i CaN'T FiND THe CoDe FoR "HOME" BuTToN...
aLL THaT i See iS CoDe FoR SiX iMaGeS... THaT HaVe MouSeoVeR aND MouSeouT FuNTioNaLiTY...

Mr J
Aug 8th, 2007, 02:10 PM
Adding such as

onload="active('mypic1','our_team_on.gif','our_team_off2.gif')"

to the opening body tag will show that link in the on state when the page loads

the mouseover and out should work as normal on the other links

Take a look at this newer version

www.huntingground.freeserve.co.uk/imagery/imglinks_m1.htm