views:

74

answers:

1

We see this occasionally in web apps on Firefox. What triggers it, and how do we prevent it? It seems to happen sporadically and the error message yields no useful information about line locations.

+2  A: 

A quick google search yielded this:

http://blowery.org/2008/02/28/object-cannot-be-created-in-this-context-code-9/

...check your code to see if you’re trying to grab a reference to the computed style on a null reference.

It appears to be connected with the Dojo framework.


Edit: Ha. Sorry I gave you your own blog as an answer. I guess I don't completely understand what you're asking for. If you want to avoid the error, you could use object checking before running the applicable code.

function isValidObject(someObject)
{
    return typeof someObject != null;
}

var obj1 = "Hello World";

if(isValidObject(obj1))
{
    //This code will run
}

if(isValidObject(ob2))
{
    //This code will not run
}

Hope that's helpful.

Andrew
That's actually my blog. :)So, that's the best I could come up with for a repro. I'm really looking to see if anyone has a more definitive answer.It's not dojo per se, but going after the computedStyle of a null, which that code happens to do.
Ben Lowery