最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Unable to get value of the property ____: object is null or undefined - Stack Overflow

programmeradmin2浏览0评论

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.

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.

Share Improve this question edited Feb 14, 2012 at 17:09 Jesse Atkinson asked Feb 14, 2012 at 16:45 Jesse AtkinsonJesse Atkinson 11.4k13 gold badges43 silver badges45 bronze badges 4
  • You could maybe show the code that actually raises the error... – Didier Ghys Commented Feb 14, 2012 at 16:47
  • The code that raises the error is simply a variable declaration. It's not even DOING anything. Just assigning a variable. The "code" is var ctlBone = window.microstrategy.bone(targetId + "_Ctl").styleHelper.ctlBone;. – Jesse Atkinson Commented Feb 14, 2012 at 17:03
  • Are you sure .bone(targetId + "_Ctl") returns something ? – Didier Ghys Commented Feb 14, 2012 at 17:13
  • Yep! Yep! and Yep! Again, this is working in Chrome, Firefox, and IE. I've console.log-ed every possible scenario I can think of and thrown in breakpoints. If I watch the object in the IE dev tools it shows up just fine. – Jesse Atkinson Commented Feb 14, 2012 at 17:40
Add a comment  | 

3 Answers 3

Reset to default 6

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/

I suggest don't wrap you jquery code with in $(document).ready(function(){ function. I have been also facing same problem after i comment that $(document).ready(function(){ it is working fine in all the browsers including IE 9 8 7 .

Try setting the browser in compatibility mode - Tools, Compatibility View Settings, and select View all web sites in compatibility mode.

发布评论

评论列表(0)

  1. 暂无评论