Please help: Problem with attachEvent in Internet Explorer
Hi
I seem to have a problem using the attachEvent method in Internet
Explorer
Here is the code:
<HTML>
<HEAD>
<STYLE TYPE="text/css">
H2 {display: inline; font-family: "Comic sans
MS",Cursive,Verdana,Arial; font-size: 16px;font-weight: bold;}
.red {color: #FF0000;}
.blue {color: #0000FF;}
</STYLE>
<SCRIPT LANGUAGE="Javascript">
function menuItemMouseOver(e) {
alert("THIS WORKS! MouseOver Component= "+e.srcElement.nodeName);
}
function defineEventHandlers() {
document.all["Football"].attachEvent("onmouseover",menuItemMouseOver);
document.all["Rugby"].attachEvent("onmouseover",menuItemMouseOver);
}
</SCRIPT>
</HEAD>
<BODY onLoad="defineEventHandlers();">
<TABLE BGCOLOR=#000000 BORDER=1 WIDTH=150 CELLSPACING=0>
<TR>
<TD ALIGN="center">
<DIV ID="Football">
<H2 CLASS="red">Football</H2><H2 CLASS="blue"> >></H2>
</DIV>
</TD>
</TR>
<TR>
<TD ALIGN="center">
<DIV ID="Rugby">
<H2 CLASS="red">Rugby</H2><H2 CLASS="blue"> >></H2>
</DIV>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
As you can see (if you test it) the event is triggered on the DIV
Component for Football (this is the behaviour I want) but only on the
H2 element for rugby.
Can someone please tell me the reason for this and how to get round
this problem? Thanks in advance. |