I have the following lines of Javascript:
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.
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?
In Internet explorer 8 JScript regular expression bug the following answer was given:
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.