在IE6和IE7简单的JavaScript字符串问题 [英] Simple javascript string problem in ie6 and ie7
问题描述
我有一个非常简单的函数,它接受逗号分隔(X,Y)点的列表,并将它们导入到一个图形。我有FF,Chrome和IE8安装。我使用IETester来测试IE6和IE7。
I have a very simple function that takes a list of comma separated (x,y) points and imports them into a graph. I have FF, Chrome and IE8 installed. I use IETester to test for IE6 and IE7.
// Import Data
this.Import = function(data) {
alert("Data in: "+data);
var d;
// Make sure the first and the last are start/ending parenthesis
if ( (data[0] != '(') || (data[data.length-1] != ')') ) {
alert("After if: "+data[0]+" "+data[data.length-1]);
return false;
}
...
在Chrome中,FF和IE8,我没有看到后,如果:警报。
在IE6和IE7,我看,以下两个警报:
在数据:(52,16),(100,90)
之后,如果:不确定不确定
In Chrome, FF and IE8, I don't see the "After if:" alert. In IE6 and IE7, I see the following two alerts: Data in: (52,16),(100,90) After if: undefined undefined
数据中的在所有浏览器的警报匹配。
The "Data in" alert matches in all browsers.
任何想法?
推荐答案
想通了。必须使用.charAt()而不是治疗字符串作为IE6数组和7。
Figured it out. Have to use .charAt() instead of treating a string as an array in ie6 and 7.
这篇关于在IE6和IE7简单的JavaScript字符串问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!