DenverMarc
Technical User
Hello,
I'm using an onmouseover and onmouseout event to change the image and text of one div when I hover over some thumbnails in another div.
It seems to work fine if I move the mouse somewhat slowly from one thumbnail to another, but if I move the mouse quickly, the text changes but the image doesn't.
I tried adding a preload event (I hope I did it correctly) but that still didn't seem to solve the problem. It also only seems to be an issue in Firefox (works in Safari, Chrome and even IE).
Here's my preload:
<script type="text/javascript" language="JavaScript">
<!--
if (document.images) {
preload_image_object = new Image();
// set image url
image_url = new Array();
image_url[0] = "images/TeamOne.jpg";
image_url[1] = "images/TeamTwo.jpg";
image_url[2] = "images/TeamThree.jpg";
image_url[3] = "images/TeamFour.jpg";
var i = 0;
for (i = 0; i <= 3; i++)
preload_image_object.src = image_url;
}
//-->
</script>
Here's the change function (in a separate javascript file):
function $(sName) {
return document.getElementById(sName);
}
function changeTeammate(teammate) {
if (teammate == "one") {
$("TeamBioImage").src = "images/TeamOne.jpg";
$("TeamBioTextOne").innerHTML = "Teammate two contact info";
$("TeamBioTextTwo").innerHTML = "Teammate one text."
}
if (teammate == "two") {
$("TeamBioImage").src = "images/TeamTwo.jpg";
$("TeamBioTextOne").innerHTML = "Teammate two contact info";
$("TeamBioTextTwo").innerHTML = "Teammate two text."
}
if (teammate == "three") {
$("TeamBioImage").src = "images/TeamThree.jpg";
$("TeamBioTextOne").innerHTML = "Teammate three contact info";
$("TeamBioTextTwo").innerHTML = "Teammate three text."
}
if (teammate == "four") {
$("TeamBioImage").src = "images/TeamFour.jpg";
$("TeamBioTextOne").innerHTML = "Teammate four contact info";
$("TeamBioTextTwo").innerHTML = "Teammate four text"
}
if (teammate == "home") {
$("TeamBioImage").src = "images/TeamAll.jpg";
$("TeamBioTextOne").innerHTML = "";
$("TeamBioTextTwo").innerHTML = "Default text here"
}
}
And here's the html:
<div id="TeamThumbnailsDiv" onmouseout="changeTeammate('home')">
<img src="images/meetTheTeam.gif" id="TeamImages" alt="Meet the team" onmouseover="changeTeammate('home')" />
<img src="images/FourBW.jpg" id="FourBW" alt="" onmouseover="changeTeammate('four')" />
<img src="images/ThreeBW.jpg" id="ThreeBW" alt="" onmouseover="changeTeammate('three')" />
<img src="images/TwoBW.jpg" id="TwoBW" alt="" onmouseover="changeTeammate('two')" />
<img src="images/OneBW.jpg" id="OneBW" alt="" onmouseover="changeTeammate('one')" />
</div>
<div id="TeamYellowBox">
<img id="TeamBioImage" name="TeamBioImage" src="images/TeamAll.jpg" alt="" />
<label id="TeamBioTextOne" class="Black12">
</label>
<label id="TeamBioTextTwo" class="Black12">Default text here.<br /><br />
</label>
</div>
Thanks,
Marc
I'm using an onmouseover and onmouseout event to change the image and text of one div when I hover over some thumbnails in another div.
It seems to work fine if I move the mouse somewhat slowly from one thumbnail to another, but if I move the mouse quickly, the text changes but the image doesn't.
I tried adding a preload event (I hope I did it correctly) but that still didn't seem to solve the problem. It also only seems to be an issue in Firefox (works in Safari, Chrome and even IE).
Here's my preload:
<script type="text/javascript" language="JavaScript">
<!--
if (document.images) {
preload_image_object = new Image();
// set image url
image_url = new Array();
image_url[0] = "images/TeamOne.jpg";
image_url[1] = "images/TeamTwo.jpg";
image_url[2] = "images/TeamThree.jpg";
image_url[3] = "images/TeamFour.jpg";
var i = 0;
for (i = 0; i <= 3; i++)
preload_image_object.src = image_url;
}
//-->
</script>
Here's the change function (in a separate javascript file):
function $(sName) {
return document.getElementById(sName);
}
function changeTeammate(teammate) {
if (teammate == "one") {
$("TeamBioImage").src = "images/TeamOne.jpg";
$("TeamBioTextOne").innerHTML = "Teammate two contact info";
$("TeamBioTextTwo").innerHTML = "Teammate one text."
}
if (teammate == "two") {
$("TeamBioImage").src = "images/TeamTwo.jpg";
$("TeamBioTextOne").innerHTML = "Teammate two contact info";
$("TeamBioTextTwo").innerHTML = "Teammate two text."
}
if (teammate == "three") {
$("TeamBioImage").src = "images/TeamThree.jpg";
$("TeamBioTextOne").innerHTML = "Teammate three contact info";
$("TeamBioTextTwo").innerHTML = "Teammate three text."
}
if (teammate == "four") {
$("TeamBioImage").src = "images/TeamFour.jpg";
$("TeamBioTextOne").innerHTML = "Teammate four contact info";
$("TeamBioTextTwo").innerHTML = "Teammate four text"
}
if (teammate == "home") {
$("TeamBioImage").src = "images/TeamAll.jpg";
$("TeamBioTextOne").innerHTML = "";
$("TeamBioTextTwo").innerHTML = "Default text here"
}
}
And here's the html:
<div id="TeamThumbnailsDiv" onmouseout="changeTeammate('home')">
<img src="images/meetTheTeam.gif" id="TeamImages" alt="Meet the team" onmouseover="changeTeammate('home')" />
<img src="images/FourBW.jpg" id="FourBW" alt="" onmouseover="changeTeammate('four')" />
<img src="images/ThreeBW.jpg" id="ThreeBW" alt="" onmouseover="changeTeammate('three')" />
<img src="images/TwoBW.jpg" id="TwoBW" alt="" onmouseover="changeTeammate('two')" />
<img src="images/OneBW.jpg" id="OneBW" alt="" onmouseover="changeTeammate('one')" />
</div>
<div id="TeamYellowBox">
<img id="TeamBioImage" name="TeamBioImage" src="images/TeamAll.jpg" alt="" />
<label id="TeamBioTextOne" class="Black12">
</label>
<label id="TeamBioTextTwo" class="Black12">Default text here.<br /><br />
</label>
</div>
Thanks,
Marc