Javascript – Unable to get value of the property ____: object is null or undefined

internet-explorerjavascriptjquery

I've researched the heck out of this. There are several posts on Stackoverflow about this already, but none seem to have an answer for me.

Like the other posts on here, it's working fine in Chrome or Firefox. But in IE 9, 8, 7, & 6 I get the same error. I've tried the hack where you force 9 into compatibility mode, but it doesn't resolve the issue.

It's saying Unable to get value of the property 'styleHelper': object is null or undefined, the irony is that if I – in IE 9 – type into the console window.microstrategy.bone("W2552_Ctl").styleHelper it works and returns the function I need (that ID was created by the WYSIWYG, don't hate me).

Yes, everything is wrapped in a $(document).ready. Yes, there are no typos. I do not get why IE hates this so much. Any help would be appreciated 🙂

The code in question is a simple variable declaration.

var ctlBone = window.microstrategy.bone(targetId + "_Ctl").styleHelper.ctlBone;

It appears that IE is trying to access that object right then and there rather than assign it.

Best Solution

FINALLY!

It was an issue with a setTimeout. Apparently setTimeout(function, miliseconds, param1, param2, param3); breaks in IE specifically.

SOURCE: http://arguments.callee.info/2008/11/10/passing-arguments-to-settimeout-and-setinterval/