wayne.blackmon
wayne.blackmon

Reputation: 761

ASP.NET MVC 3: Microsoft JScript runtime error: Object doesn't support property or method 'addEventListener'

Error context:

Visual Studio 2010 Service Pack 1 ASP.NET MVC 3 Application IE9 with Script Debugging enabled for Internet Explorer

Error conditions:

Execution stops int a JavaScript file called "script block [dynamic]" at the following line

doc.addEventListener("DOMNodeInserted", onDOMNodeInserted, false);

that line of code is nested inside the following if block

if (ver >= 9.0)
{
    doc.addEventListener("DOMNodeInserted", onDOMNodeInserted, false);
    doc.addEventListener("DOMNodeInsertedIntoDocument", onDOMNodeInsertedIntoDocument, false);
}

This is a very persistent error that started happening after I re-imaged my hard drive and reinstalled VS 2010 SP1 and ASP.NET MVC 3. I did it twice to make sure I did it right.

I am going to take a guess and suggest that this bug is the side affect of an un-handled exception in ASP.NET MVC 3 or a bug in IE9. The error seems to ocurr when a (GET?) action method cannot be found that is specified in the ActionLink HTML helper method such as

@Html.ActionLink("Link Text", "Action")

I believe that IE9 does support addEventListener so the error itself is incorrect. Unless I can get more info this error is beyond my ability to fix its cause. I can prevent it by making sure that my action method is there and that it works. That is a workaround not a fix. Fixing the error would prevent it from being erroneously reported because IE9 does in fact support addEventListener.

Upvotes: 1

Views: 3045

Answers (3)

PTansey
PTansey

Reputation: 576

I turned off Compatibility Mode (was running on local intranet) and the problem went away.

Upvotes: 0

Allen Gawthrop
Allen Gawthrop

Reputation: 11

I've been getting this error today while working on a VS 2010 project, I was using IE9 for my browser. Turns out it's an erroneous message, I should have been getting a page not found error. I tried disabling Divx as mentioned above, but that didn't help. I then tried using Chrome and it reported my error correctly and I was able to solve my problem. If you get this error, try a different browser which may point you in the right direction.

Upvotes: 1

wayne.blackmon
wayne.blackmon

Reputation: 761

An answer has been found to this question. The problem was caused by the Divix browser plugin

Solution: Object doesn't support property or method 'addEventListener'

Thank you to a poster on the asp.net forums for helping to solve this problem. The Divix browser plugin has recently been updated. The update may have fixed this issue. However, it remains disabled on my system. Disabling the Divx plug-in definitely fixed this issue for myself and others. I have reported this bug to Divx support.

Upvotes: 4

Related Questions