Connecting Tech Pros Worldwide Help | Site Map

Please help: Problem with attachEvent in Internet Explorer

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 20th, 2005, 12:00 PM
christian9997
Guest
 
Posts: n/a
Default 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"> &gt;&gt;</H2>
</DIV>
</TD>
</TR>
<TR>
<TD ALIGN="center">
<DIV ID="Rugby">
<H2 CLASS="red">Rugby</H2><H2 CLASS="blue"> &gt;&gt;</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.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.