This script works in Opera 9, IE 6 and IE 7, but not in Firefox ?
JS:
[code]
function d2h(d) {return d.toString(16);} // Thanks Felgall! [got it from from javascript.about.com]
var anim = {
startVal: 223,
endVal: 244,
curVal: 223,
aObj: null,
tOut: null,
start: function(obj) {
if (anim.tOut) clearTimeout(anim.tOut);
if (obj) {
anim.aObj = obj;
anim.curVal = anim.startVal;
}
anim.curVal++;
anim.aObj.style.backgroundColor = “#” + d2h(anim.curVal) + d2h(anim.curVal) + d2h(anim.curVal); // line 15
if (anim.curVal < anim.endVal) {
anim.tOut = setTimeout(anim.start, 20);
}
},
end: function() {
if (anim.tOut) clearTimeout(anim.tOut);
anim.aObj.style.backgroundColor = “#” + d2h(anim.startVal) + d2h(anim.startVal) + d2h(anim.startVal);
}
}
HTML:
[code]
<a href=”#” onMouseOver=”anim.start(this)” onMouseOut=”anim.end()”>Page 1</a>
<a href=”#” onMouseOver=”anim.start(this)” onMouseOut=”anim.end()”>Page 2</a>
<a href=”#” onMouseOver=”anim.start(this)” onMouseOut=”anim.end()”>Page 3</a>
<a href=”#” onMouseOver=”anim.start(this)” onMouseOut=”anim.end()”>Page 4</a>
This is what FireBug is showing me:
[code]
anim.aObj.style has no properties
start(-20)common.js (line 15)
anim.aObj.style.backgroundColor = “#” + d2h(anim.curVal) + d2h(anim.curVal) + …
The error occurs on the second function call.
Please help ?