跳到IE9的一个坑里了(枚举 JavaScript 属性)

有一段Json如下

[{"SaleName_ID":"0","SaleName":"","28":"45","14":"20","13":"40","8":"50","SSD_ChargesType":"1","SSD_SaleSetType":"0"},
{"SaleName_ID":"1","SaleName":"SeleA","28":"1","14":"1","13":"1","8":"1","SSD_ChargesType":"2","SSD_SaleSetType":"1"},
{"SaleName_ID":"2","SaleName":"SeleB","28":"2","14":"2","13":"2","8":"2","SSD_ChargesType":"2","SSD_SaleSetType":"1"},
{"SaleName_ID":"3","SaleName":"SeleC","28":"3","14":"3","13":"3","8":"3","SSD_ChargesType":"2","SSD_SaleSetType":"1"},
{"SaleName_ID":"4","SaleName":"SeleD","28":"4","14":"4","13":"4","8":"4","SSD_ChargesType":"2","SSD_SaleSetType":"1"}]

因为中间的列数有可能多也有可能少,不知道列名,所以只能用for in的办法来解决

JS代码如下

for (var Row in SetSaleDetailJson) {
for (var key in SetSaleDetailJson[Row])
{ $("#zw").append(key + "=" + SetSaleDetailJson[Row][key] + ",");
}
$("#zw").append("<br>");
}

在IE8中firefox12.0中结果如下(是我想要的结果)

SaleName_ID=0,SaleName=,28=45,14=20,13=40,8=50,SSD_ChargesType=1,SSD_SaleSetType=0,
SaleName_ID=1,SaleName=SeleA,28=1,14=1,13=1,8=1,SSD_ChargesType=2,SSD_SaleSetType=1,
SaleName_ID=2,SaleName=SeleB,28=2,14=2,13=2,8=2,SSD_ChargesType=2,SSD_SaleSetType=1,
SaleName_ID=3,SaleName=SaleC,28=3,14=3,13=3,8=3,SSD_ChargesType=2,SSD_SaleSetType=1,
SaleName_ID=4,SaleName=SaleD,28=4,14=4,13=4,8=4,SSD_ChargesType=2,SSD_SaleSetType=1,

但是到了IE9,IE10中就变成如下的结果了

8=50,13=40,14=20,28=45,SaleName_ID=0,SaleName=,SSD_ChargesType=1,SSD_SaleSetType=0,
8=1,13=1,14=1,28=1,SaleName_ID=1,SaleName=SeleA,SSD_ChargesType=2,SSD_SaleSetType=1,
8=2,13=2,14=2,28=2,SaleName_ID=2,SaleName=SeleB,SSD_ChargesType=2,SSD_SaleSetType=1,
8=3,13=3,14=3,28=3,SaleName_ID=3,SaleName=SaleC,SSD_ChargesType=2,SSD_SaleSetType=1,
8=4,13=4,14=4,28=4,SaleName_ID=4,SaleName=SeleD,SSD_ChargesType=2,SSD_SaleSetType=1,

这明显列的顺序改变了。。。

后来在官方找到了IE兼容性的一篇文章

http://msdn.microsoft.com/en-us/library/ie/gg622937%28v=vs.85%29.aspx

提到这一点,尼玛居然不给解决办法,心中的千万匹的草尼玛在奔腾...

现在只能根据浏览器来判断重新写了,有哪位知道有好办法解决的给告诉一下啊

上一篇:Android 调用图库选择图片实现和参数详解


下一篇:ecshop 进入后台登录帐号出现乱码解决方法