我有一个非常简单的函数,它采用逗号分隔的 (x,y) 点列表并将它们导入到图形中。我安装了 FF、Chrome 和 IE8。我使用 IETester 来测试 IE6 和 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 中,我没有看到“After if:”警告。 在 IE6 和 IE7 中,我看到以下两个警报: 数据在:(52,16),(100,90) 在 if: undefined undefined 之后
“Data in”警告在所有浏览器中匹配。
有什么想法吗?
最佳答案
想通了。必须使用 .charAt() 而不是在 ie6 和 7 中将字符串视为数组。
关于javascript - ie6和ie7中简单的javascript字符串问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2526019/