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

javascript - IE11: indexOf() not working on one page, but working on others - Stack Overflow

programmeradmin0浏览0评论

I have several pages that use the same script, and on one page I'm getting the error "Object doesn't support property or method 'indexOf'". The error is on this line:

var giftBChecked = this.config.giftFeatures[giftB].indexOf(i) < 0 ? '' : checkimg;

In the debugger, I verified that this.config.giftFeatures[giftB] is an array. When I step through the code, I can see that it is an array of size 8, but then I get the 'indexOf' error anyway.

So it's not a patibility issue, my variable that I'm using indexOf on is not null, and the script works without error in other pages.

You can see yourself here:

Not working

Working

What is causing it to break on that one page?!

I have several pages that use the same script, and on one page I'm getting the error "Object doesn't support property or method 'indexOf'". The error is on this line:

var giftBChecked = this.config.giftFeatures[giftB].indexOf(i) < 0 ? '' : checkimg;

In the debugger, I verified that this.config.giftFeatures[giftB] is an array. When I step through the code, I can see that it is an array of size 8, but then I get the 'indexOf' error anyway.

So it's not a patibility issue, my variable that I'm using indexOf on is not null, and the script works without error in other pages.

You can see yourself here:

Not working

Working

What is causing it to break on that one page?!

Share Improve this question asked Mar 3, 2015 at 21:06 Erica Stockwell-AlpertErica Stockwell-Alpert 4,86311 gold badges67 silver badges139 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 10

On the page that isn't working you have a meta tag:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8">

That's telling the browser to emulate IE 8. IE is dutifully cooperating and acting like IE 8. IE 8 doesn't support indexOf on arrays, that didn't e until IE 9.

发布评论

评论列表(0)

  1. 暂无评论