0

I have the following js code:

if ( event.target !== self.element[ 0 ]){
  ...
 } 

In IE browser I get this error: Object doesn't support this property or method

when I write my code :

if ( event.target == self.element[ 0 ]){
  ...
 } 

I don't get a js problem

what is not supported by IE? the !==?!!

5
  • Out of curiosity if nothing else, what does === result in? Commented Mar 24, 2014 at 14:41
  • Clear the cache and try again Commented Mar 24, 2014 at 14:43
  • 2
    The issue may be within the ... rather than the condition. Between the 2 snippets, they may not both execute the block. Commented Mar 24, 2014 at 14:44
  • @JonathanLonowski it appears that @nannou is using ... (an ellipsis) as a placeholder for the code. Commented Mar 24, 2014 at 14:52
  • @jsve Sorry. Yeah. I didn't mean to suggest otherwise. Just meant that the code represented by ... may also be contributing to the "fine in one, error in the other." Commented Mar 24, 2014 at 16:21

1 Answer 1

4

Well there's no "target" property in IE; it's event.srcElement. So try

if ((event.target || event.srcElement) !== self.element[0]) 
Sign up to request clarification or add additional context in comments.

2 Comments

You are right, just one more information, on IE you need to access event objet with window.event, so you must define this before : code evt = evt || window.event;
@radia yes, that too!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.