IE event order problem

L

Larax

I'm fighting with a strange problem that occures in IE, but let's start
from beggining...

I have a DIV element and SPAN element inside it, DIV has a onClick
event attached while SPAN doesn't. The problem is, when you click at
SPAN element and onClick function is called, the event.srcElement
contains SPAN element.. I have NO idea why - from logical point, it
should contain DIV element (in FF currentTarget is correctly pointing
to DIV element)

I will be grateful for any help, I ran out of ideas..
 
R

RobG

Larax said:
I'm fighting with a strange problem that occures in IE, but let's start
from beggining...

I have a DIV element and SPAN element inside it, DIV has a onClick
event attached while SPAN doesn't. The problem is, when you click at
SPAN element and onClick function is called, the event.srcElement
contains SPAN element.. I have NO idea why - from logical point, it
should contain DIV element (in FF currentTarget is correctly pointing
to DIV element)

No it shouldn't, IE's event.srcElement is equivalent to the W3C's
event.target. There is no MS equivalent (AFAIK) to the W3C's
event.currentTarget.


W3C - Event.target:
<URL:
http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-Event-target
MS - Event.srcElement:
<URL:
http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/srcelement.asp
W3C - Event.currentTarget:
<URL:
http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-Event-currentTarget
I will be grateful for any help, I ran out of ideas..

As suggested elsewhere, the this keyword is a better option to identify
the element that called the function.
 
L

Larax

Thanks for help, it seems that I have no other choice than using this
keyword.. We all love IE, doesn't we? ;P
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,121
Latest member
LowellMcGu
Top