JavaScript issue

Jazajay

Active Member
Hay I've been trying to get this to work in Firefox and at the mo it just wont and I can't see why both events are firing at once.

What is meant to happen is when a link is hovered over, a box appears with text, then when the mouse is moved off the box disappears, simple right.

What happens is the first time you load the page and move your mouse over it the box appears for a split second then disappears. If you then hover over the link a second time nothing happens.

This 5 min job has for some reason turned into an half hour job and I can't spend any more time on it today nor can I see why it is doing it.

var js={
nav:document.getElementById("w3").getElementsByTagName("li"),
head:function(){
var a1=js.nav[1].getElementsByTagName("a");
js.addEvent(a1[0],"mouseover",js.pop1,false);
js.addEvent(a1[0],"mouseout",js.out1,false);
},
pop1:function(){
js.nav[1].innerHTML=js.nav[1].innerHTML+"<div id='pop1'>Enter a few details into our weight loss calculator and we'll tell you how much weight you should lose by the end of the week.</div>";
},
out1:function(){
js.nav[1].removeChild(document.getElementById("pop1"));
},
addEvent:function(ele,ty,fun,capt){
if(!ele){return;}
if(ele.addEventListener){
ele.addEventListener(ty,fun,capt);
return true;
}else if(ele.attachEvent){
var r=ele.attachEvent('on'+ty,fun);
return r;
}else{ele['on',ty]=fun;}
}
}
js.addEvent(window,"load",js.head,false);
I would be seriously appreciative if people can tell me why I am being a dumbass. :)
 
Back
Top