javascript - IE11 : indexOf() not working on one page, 但正在处理其他问题

标签 javascript internet-explorer indexof

我有几个使用相同脚本的页面,其中一个页面出现错误“对象不支持属性或方法‘indexOf’”。错误在这一行:

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

在调试器中,我验证了 this.config.giftFeatures[giftB] 是一个数组。当我单步执行代码时,我可以看到它是一个大小为 8 的数组,但无论如何我都会收到“indexOf”错误。

所以这不是兼容性问题,我在其上使用 indexOf 的变量不为 null,并且该脚本在其他页面中正常运行。

你可以在这里看到你自己:

Not working

Working

是什么导致它在那个页面上中断?!

最佳答案

在无法正常工作的页面上,您有一个元标记:

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

这告诉浏览器模拟 IE 8。IE 尽职尽责地合作并像 IE 8 一样行事。IE 8 不支持数组上的 indexOf,直到 IE 9 才出现。

关于javascript - IE11 : indexOf() not working on one page, 但正在处理其他问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28841890/

相关文章:

javascript - Node.JS 如何设置当前范围之外的变量

html - CSS 伪元素 :before & :after work differently in Internet Explorer

JavaScript indexOf() 函数在 VB.Net 中失败

javascript - 在 javascript 中查找上下文相关的子字符串

javascript - 拆分 window.location on/并与 : if ends in/don't add : 连接

javascript - Angular : Cannot call method 'replace' of undefined Android Browser

JavaScript:如何获取字符串形式的代码?

javascript - 如何获取丰富的光标位置:editor richfaces by javascript

css - 当 <a> 位于另一个元素上方时,IE 中的文本显示问题

javascript - 为什么 window.open(url, name) 不能在 IE11 的同一个窗口中打开?