Tharnid
03-28-2008, 05:27 AM
Ok I am trying to put four image rollovers on a page and here is what I have so far:
<script language="javascript 2.1" type="text/javascript">
<!--
//PRE-LOAD IMAGES AS JS IMAGE OBJECTS
var imgajaxianOver = new Image(1);
var imgajaxianOriginal = new Image(1);
var imgajaxianDown = new Image(1);
imgajaxianOver.src = "Images/ajaxianOver.jpg";
imgajaxianOriginal.src = "Images/ajaxianOriginal.jpg";
imgajaxianDown.src = "Images/ajaxianDown.jpg";
function mouseOver(intImgIndex)
{
window.document.images[intImgIndex].src = imgajaxianOver.src;
}//end mouseOver()
function mouseOut(intImgIndex)
{
window.document.images[intImgIndex].src = imgajaxianOriginal.src;
}//end mouseOut()
function mouseDown(intImgIndex)
{
window.document.images[intImgIndex].src = imgajaxianDown.src;
}//end mouseDown()*/
//PRE-LOAD IMAGES AS JS IMAGE OBJECTS
var imgatpTennisOver = new Image(0);
var imgatpTennisOriginal = new Image(0);
var imgatpTennisDown = new Image(0);
imgatpTennisOver.src = "Images/atpTennisOver.jpg";
imgatpTennisOriginal.src = "Images/atpTennisOriginal.jpg";
imgatpTennisDown.src = "Images/atpTennisDown.jpg";
function mouseOver(intImgIndex2)
{
window.document.images[intImgIndex2].src = imgatpTennisOver.src;
}//end mouseOver()
function mouseOut(intImgIndex2)
{
window.document.images[intImgIndex2].src = imgatpTennisOriginal.src;
}//end mouseOut()
function mouseDown(intImgIndex2)
{
window.document.images[intImgIndex].src = imgatpTennisDown.src;
}//end mouseDown()
</script>
My question is for each set of names do I need increase the following:
var imgatpTennisOver = new Image(0);
var imgatpTennisOriginal = new Image(0);
var imgatpTennisDown = new Image(0);
to:
var imgatpTennisOver = new Image(1);
var imgatpTennisOriginal = new Image(1);
var imgatpTennisDown = new Image(1);
The problem is that that both the images will display however when you rollover the bottom image the top image disappears and is replaced by the bottom image. I can get one image to work fine...the second one does not for some reason :confused: Here is my HTML code so far....
<body>
<p align = "center">
<a href = "#"
onClick = "return false"
name = "dummyLink"
id = "dummyLink"
onMouseOver = "javascript:mouseOver(1);"
onMouseOut = "javascript:mouseOut(1);"
onMouseDown = "javascript:mouseDown(1);"
onMouseUp = "javascript:mouseOver(1);"
style = "border:0">
<img src = "Images/ajaxianOriginal.jpg"
name = "image1"
id = "image1"
style = "border:0" /></a>
</p>
<p align = "center">
<a href = "#"
onClick = "return false"
name = "dummyLink2"
id = "dummyLink2"
onMouseOver = "javascript:mouseOver(0);"
onMouseOut = "javascript:mouseOut(0);"
onMouseDown = "javascript:mouseDown(0);"
onMouseUp = "javascript:mouseOver(0);"
style = "border:0">
<img src = "Images/atpTennisOriginal.jpg"
name = "image2"
id = "image2"
style = "border:0" /></a>
</p>
</body>
I just do not get what the problem would be :eek: If anyone could provide a direction that would be great :)
<script language="javascript 2.1" type="text/javascript">
<!--
//PRE-LOAD IMAGES AS JS IMAGE OBJECTS
var imgajaxianOver = new Image(1);
var imgajaxianOriginal = new Image(1);
var imgajaxianDown = new Image(1);
imgajaxianOver.src = "Images/ajaxianOver.jpg";
imgajaxianOriginal.src = "Images/ajaxianOriginal.jpg";
imgajaxianDown.src = "Images/ajaxianDown.jpg";
function mouseOver(intImgIndex)
{
window.document.images[intImgIndex].src = imgajaxianOver.src;
}//end mouseOver()
function mouseOut(intImgIndex)
{
window.document.images[intImgIndex].src = imgajaxianOriginal.src;
}//end mouseOut()
function mouseDown(intImgIndex)
{
window.document.images[intImgIndex].src = imgajaxianDown.src;
}//end mouseDown()*/
//PRE-LOAD IMAGES AS JS IMAGE OBJECTS
var imgatpTennisOver = new Image(0);
var imgatpTennisOriginal = new Image(0);
var imgatpTennisDown = new Image(0);
imgatpTennisOver.src = "Images/atpTennisOver.jpg";
imgatpTennisOriginal.src = "Images/atpTennisOriginal.jpg";
imgatpTennisDown.src = "Images/atpTennisDown.jpg";
function mouseOver(intImgIndex2)
{
window.document.images[intImgIndex2].src = imgatpTennisOver.src;
}//end mouseOver()
function mouseOut(intImgIndex2)
{
window.document.images[intImgIndex2].src = imgatpTennisOriginal.src;
}//end mouseOut()
function mouseDown(intImgIndex2)
{
window.document.images[intImgIndex].src = imgatpTennisDown.src;
}//end mouseDown()
</script>
My question is for each set of names do I need increase the following:
var imgatpTennisOver = new Image(0);
var imgatpTennisOriginal = new Image(0);
var imgatpTennisDown = new Image(0);
to:
var imgatpTennisOver = new Image(1);
var imgatpTennisOriginal = new Image(1);
var imgatpTennisDown = new Image(1);
The problem is that that both the images will display however when you rollover the bottom image the top image disappears and is replaced by the bottom image. I can get one image to work fine...the second one does not for some reason :confused: Here is my HTML code so far....
<body>
<p align = "center">
<a href = "#"
onClick = "return false"
name = "dummyLink"
id = "dummyLink"
onMouseOver = "javascript:mouseOver(1);"
onMouseOut = "javascript:mouseOut(1);"
onMouseDown = "javascript:mouseDown(1);"
onMouseUp = "javascript:mouseOver(1);"
style = "border:0">
<img src = "Images/ajaxianOriginal.jpg"
name = "image1"
id = "image1"
style = "border:0" /></a>
</p>
<p align = "center">
<a href = "#"
onClick = "return false"
name = "dummyLink2"
id = "dummyLink2"
onMouseOver = "javascript:mouseOver(0);"
onMouseOut = "javascript:mouseOut(0);"
onMouseDown = "javascript:mouseDown(0);"
onMouseUp = "javascript:mouseOver(0);"
style = "border:0">
<img src = "Images/atpTennisOriginal.jpg"
name = "image2"
id = "image2"
style = "border:0" /></a>
</p>
</body>
I just do not get what the problem would be :eek: If anyone could provide a direction that would be great :)