[英]Javascript and Internet explorer 8 error
I have the following lines of Javascript: 我有以下几行Java语言:
function SetTabIndex() {
var test = document.getElementsByTagName("input");
for (var i = 0; i < test.length; i++) {
var cssText = test[i].getAttribute('style'),
tabindex = cssText.match(/tabindex\s*:\s*(\d+)/);
if (tabindex) {
test[i].setAttribute('tabindex', tabindex[1]);
}
}
}
When I run this locally, the script runs and does exactly what I want it to. 当我在本地运行此脚本时,该脚本将运行并完全执行我想要的操作。 But, when I put this on my target system (which only has IE8 and can't be updated) the code doesn't run.
但是,当我将其放在目标系统(仅具有IE8并且无法更新)上时,代码将无法运行。
I've checked my log and I get the following error: 我检查了日志,并收到以下错误:
Object doesn't support this property or method
对象不支持此属性或方法
When I click the link next to it, it takes me to the following line of code: 当我单击它旁边的链接时,它将带我到以下代码行:
tabindex = cssText.match(/tabindex\s*:\s*(\d+)/);
I've tried taking out some of my regex code, but it still throws up an error. 我尝试取出一些正则表达式代码,但仍然会引发错误。 When I take that line away and throw in some console outputs, everything works fine.
当我把那条线拿走并投入一些控制台输出时,一切正常。
Is there a particular reason as to why this doesn't work on IE8 even though I tested it locally on my more updated version of IE with it set to emulate IE8 just fine? 即使我在较新版本的IE上进行本地测试并设置为可以很好地模拟IE8,为什么它在IE8上不起作用有一个特殊的原因吗?
In Internet explorer 8 JScript regular expression bug the following answer was given: 在Internet Explorer 8 JScript正则表达式错误中 ,给出了以下答案:
The issue here was that
"\\s"
in javascript does not include a non breaking space in IE but includes a non breaking space in FF.这里的问题是,javascript中的
"\\s"
在IE中不包含不间断空格,而在FF中包含不间断空格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.