O
Owen Brunker
Hello All,
I have written a Javascript class to handle mouse overs. I cant see
anything wrong with the logic, but it doesn't work. I have included the
class code below. Does anyone have any ideas that can point me in the right
direction. I have confirmed that the event methods are being called. None
of the browsers report any errors. The problem is that the images are not
swapped.
Thanks in advance
Owen Brunker
function MouseOvers() {
this.ImageItems = new Array();
this.IdIndex = new Array();
this.addItem = addElementItem;
this.findIndex = findIndex;
this.takeMouseOver = takeMouseOverEvent;
this.takeMouseOut = takeMouseOutEvent;
this.takeMouseDown = takeMouseDownEvent;
}
function findIndex(id) {
var ReturnValue = null;
var i;
for (i = 0; i < this.IdIndex.length; i++)
if (this.IdIndex == id) {
ReturnValue = i;
break;
}
return ReturnValue;
}
function addElementItem(id, ImgStandard, ImgMouseOver, ImgMouseDown) {
var Itemindex;
Itemindex = this.ImageItems.length;
this.ImageItems[Itemindex] = new Object();
this.IdIndex[Itemindex] = id;
this.ImageItems[Itemindex].ImgStandard = new Image;
this.ImageItems[Itemindex].ImgStandard.src = ImgStandard;
this.ImageItems[Itemindex].ImgMouseOver = new Image;
this.ImageItems[Itemindex].ImgMouseOver.src = ImgMouseOver;
this.ImageItems[Itemindex].ImgMouseDown = new Image;
this.ImageItems[Itemindex].ImgMouseDown.src = ImgMouseDown;
}
function takeMouseOverEvent(id) {
var Itemindex;
var element;
var d = document;
if (Itemindex = this.findIndex(id))
if (document.images)
document.images[id].src = this.ImageItems[Itemindex].ImgMouseOver.src;
// element = d.getElementById(id);
// if (element != null)
// element.src = this.ImageItems[Itemindex].ImgMouseOver.src;
}
function takeMouseOutEvent(id) {
var Itemindex;
var element;
var d = document;
element = d.getElementById(id);
if (element != null)
if (Itemindex = this.findIndex(id))
element.src = this.ImageItems[Itemindex].ImgStandard.src;
}
function takeMouseDownEvent(id) {
var Itemindex;
var element;
var d = document;
element = d.getElementById(id);
if (element != null)
if (Itemindex = this.findIndex(id))
element.src = this.ImageItems[Itemindex].ImgMouseDown.src;
}
I have written a Javascript class to handle mouse overs. I cant see
anything wrong with the logic, but it doesn't work. I have included the
class code below. Does anyone have any ideas that can point me in the right
direction. I have confirmed that the event methods are being called. None
of the browsers report any errors. The problem is that the images are not
swapped.
Thanks in advance
Owen Brunker
function MouseOvers() {
this.ImageItems = new Array();
this.IdIndex = new Array();
this.addItem = addElementItem;
this.findIndex = findIndex;
this.takeMouseOver = takeMouseOverEvent;
this.takeMouseOut = takeMouseOutEvent;
this.takeMouseDown = takeMouseDownEvent;
}
function findIndex(id) {
var ReturnValue = null;
var i;
for (i = 0; i < this.IdIndex.length; i++)
if (this.IdIndex == id) {
ReturnValue = i;
break;
}
return ReturnValue;
}
function addElementItem(id, ImgStandard, ImgMouseOver, ImgMouseDown) {
var Itemindex;
Itemindex = this.ImageItems.length;
this.ImageItems[Itemindex] = new Object();
this.IdIndex[Itemindex] = id;
this.ImageItems[Itemindex].ImgStandard = new Image;
this.ImageItems[Itemindex].ImgStandard.src = ImgStandard;
this.ImageItems[Itemindex].ImgMouseOver = new Image;
this.ImageItems[Itemindex].ImgMouseOver.src = ImgMouseOver;
this.ImageItems[Itemindex].ImgMouseDown = new Image;
this.ImageItems[Itemindex].ImgMouseDown.src = ImgMouseDown;
}
function takeMouseOverEvent(id) {
var Itemindex;
var element;
var d = document;
if (Itemindex = this.findIndex(id))
if (document.images)
document.images[id].src = this.ImageItems[Itemindex].ImgMouseOver.src;
// element = d.getElementById(id);
// if (element != null)
// element.src = this.ImageItems[Itemindex].ImgMouseOver.src;
}
function takeMouseOutEvent(id) {
var Itemindex;
var element;
var d = document;
element = d.getElementById(id);
if (element != null)
if (Itemindex = this.findIndex(id))
element.src = this.ImageItems[Itemindex].ImgStandard.src;
}
function takeMouseDownEvent(id) {
var Itemindex;
var element;
var d = document;
element = d.getElementById(id);
if (element != null)
if (Itemindex = this.findIndex(id))
element.src = this.ImageItems[Itemindex].ImgMouseDown.src;
}